Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/8.0' into 9.0-for-merger-30031…
Browse files Browse the repository at this point in the history
…7-b7274d0
  • Loading branch information
iledarn committed Mar 30, 2017
2 parents e6397db + 7f3dbb1 commit 44b6f94
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: python
python:
- "2.7"

dist: trusty
sudo: false
cache: pip

Expand Down
2 changes: 1 addition & 1 deletion pos_longpolling/static/src/js/pos_longpolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ odoo.define('pos_longpolling', function(require){
update_status: function(message) {
var self = this;
if (this.pos.debug) {
console.log("Message: ", message);
console.log("This message from server. Message: ", message);
}
self.stop_timer();
self.set_status(true);
Expand Down
1 change: 1 addition & 0 deletions pos_multi_session/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png
8 changes: 8 additions & 0 deletions pos_multi_session/doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Updates
- NEW: Added connection status with server to POS interface
- NEW: Create new orders even if the connection with server temporarily has been lost

`3.0.0`
-------

- FIX: Added a queue for request sending that allows to fix the syncronization error on slow or lost connection
- NEW: Added connection status with server to POS interface
- NEW: Create new orders even if the connection with server temporarily has been lost


`2.0.1`
-------

Expand Down
14 changes: 13 additions & 1 deletion pos_multi_session/external_tests/phantomtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Modified phantomtest.js from odoo ( https://github.com/odoo/odoo/blob/8.0/opener
[{"session": "session1",
"extra": "connection_on" | "connection_off" | "connection_slow"
"screenshot": screenshot_name,
"code": "console.log('ok')",
"ready": false, # wait before calling next command
"timeout": 60000, # code execution timeout
Expand All @@ -28,6 +29,11 @@ Modified phantomtest.js from odoo ( https://github.com/odoo/odoo/blob/8.0/opener
* to communicate between commands, variable ``share`` can be used. It's saved right after execution finish. It's not save in async code (e.g. inside setTimeout function)
* screenshot:
* make screenshot before execution of the code
* filename is SESSION-SCREENSHOT-NUM.png
*/

var system = require('system');
Expand Down Expand Up @@ -250,10 +256,16 @@ function PhantomTest() {
sname = command.session;
page = self.pages[sname];
extra = command.extra;
screenshot = command.screenshot;
code = command.code || 'true';
ready = command.ready || 'true';

console.log("PhantomTest.runCommands: executing: " + code);
if (screenshot){
console.log('Make screenshot', screenshot);
page.render(sname + '-' + screenshot + '-' + i + '.png');
}

console.log("PhantomTest.runCommands: executing as "+sname+ ": " + code);
(function(){
var commandNum = i;
timer = setTimeout(function () {
Expand Down
14 changes: 11 additions & 3 deletions pos_multi_session/external_tests/tests/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ window.mstest = {
$('.order-sequence').each(function(){
var order_num = $.trim($(this).html()).split("\n");
if (parseInt(order_num[2]) == order.order_num){
$(this).click();
if (!$(this).parent().hasClass('selected')){
// click only on inactive tab.
// Otherwise Customer Selection screen will be opened
$(this).click();
}
return false;
}
});
Expand Down Expand Up @@ -117,7 +121,11 @@ window.mstest = {
setTimeout(function(){
callback();
mstest.is_wait = false;
}, timeout || 1000);
}, timeout || 3000);
},
check_revision_error: function(){
warning_message = 'There is a conflict during synchronization, try your action again';
if ($('.modal .in').text() == warning_message)
console.log('error', warning_message);
},

};
91 changes: 87 additions & 4 deletions pos_multi_session/external_tests/tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,23 @@ def test_20_offline_update_order(self):
"code": """
mstest.fill_order();
share.order = mstest.get_order();
mstest.wait(function(){
mstest.check_revision_error();
}, 5000)
""",
},
# check sync on demo
{"session": "demo",
"code": """
mstest.wait(function(){
mstest.find_order(share.order);
}, 20000)
}, 10000)
""",
"timeout": 25000,
},
# ok
{"session": "demo",
"screenshot": "test-20-final",
"code": "console.log('ok');",
},
], 240)
Expand All @@ -202,7 +206,7 @@ def test_21_offline_remove_order(self):
# admin removes orders
{"session": "admin",
"code": """
console.log('test_20_offline');
console.log('test_21_offline_remove_order');
mstest.remove_all_orders();
""",
},
Expand Down Expand Up @@ -264,6 +268,7 @@ def test_21_offline_remove_order(self):
# demo creates new order (to start reconnection process)
{"session": "demo",
"code": """
console.log('demo creates new order (to start reconnection process)')
mstest.new_order();
mstest.fill_order();
mstest.wait(function(){
Expand Down Expand Up @@ -396,9 +401,9 @@ def test_30_slow(self):
synced_order = mstest.get_order();
mstest.check_inclusion(share.admin_order, synced_order);
}, 10000)
}, 20000)
""",
"timeout": 20000,
"timeout": 30000,
},
# demo compares order with his initial order
{"session": "demo",
Expand All @@ -418,3 +423,81 @@ def test_30_slow(self):
"code": "console.log('ok');",
},
], 120)

def test_31_queue(self):
"""Single POS send two update request.
It would raise error 'sync conflicts', if there are no queue for sending updates. For example
* Order has revision_ID equal to 10
* We send first update
* We send second update
* First request is reached the server. Server sets revision_ID equal to 11
* Second request is reached the server. Server return revision_error, because in request revision_ID is 10, while server has revision_ID 11
"""

# current postpone timer for sending updates is 1000 ms
# connection_slow delay response to 3000 ms

self.phantom_js_multi({
# use default settings for sessions (see ./common.py)
"admin": {},
}, [
# admin removes orders
{"session": "admin",
"code": """
console.log('test_31_slow');
mstest.remove_all_orders();
""",
},
# admin creates order
{"session": "admin",
"code": """
mstest.fill_order();
mstest.print_order();
mstest.wait(function(){
})
""",
},

# response for admin requests are delayed for 3 seconds
{"session": "admin",
"extra": "connection_slow",
"code": """
console.log("admin requests are delayed")
""",
},
# admin updates order
{"session": "admin",
"code": """
console.log('Admin updates Order')
mstest.fill_order();
console.log('Admin waits to send update request')
mstest.wait(function(){
}, 1500)
""",
},
# admin updates order again
{"session": "admin",
"code": """
console.log('Admin updates Order again')
mstest.fill_order();
""",
},
# admin waits and receives error if queue doesn't work
{"session": "admin",
"code": """
mstest.wait(function(){
mstest.check_revision_error();
}, 10000)
""",
"timeout": 20000,
},
# connection is on
{"session": "admin",
"extra": "connection_on",
},
# ok
{"session": "admin",
"screenshot": "test-31-final",
"code": "console.log('ok');",
},
], 120)
17 changes: 17 additions & 0 deletions pos_multi_session/static/src/xml/pos_multi_session.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,21 @@
</t>
</t>

<t t-name="PreloadPopupWidget">
<div class="modal-dialog modal-popup-preload">
<div class="popup popup-preload">
<div id="floatingCirclesG">
<div class="f_circleG" id="frotateG_01"></div>
<div class="f_circleG" id="frotateG_02"></div>
<div class="f_circleG" id="frotateG_03"></div>
<div class="f_circleG" id="frotateG_04"></div>
<div class="f_circleG" id="frotateG_05"></div>
<div class="f_circleG" id="frotateG_06"></div>
<div class="f_circleG" id="frotateG_07"></div>
<div class="f_circleG" id="frotateG_08"></div>
</div>
</div>
</div>
</t>

</templates>

0 comments on commit 44b6f94

Please sign in to comment.