From 71ae60324bfa475ab071d783a0e6ea34c0c76ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 5 Sep 2013 12:43:57 +0200 Subject: [PATCH 01/14] [IMP] point_of_sale: sane multi order workflow + remove existing tooltips when we load the pos bzr revid: fva@openerp.com-20130905104357-xlf51euhnclymj7x --- addons/point_of_sale/static/src/css/pos.css | 11 +++++++-- addons/point_of_sale/static/src/js/models.js | 21 +++++++++++++---- addons/point_of_sale/static/src/js/widgets.js | 23 ++++++++++--------- addons/point_of_sale/static/src/xml/pos.xml | 3 ++- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index e328054aa28..2294513a389 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -175,10 +175,9 @@ background: linear-gradient(#b2b3d7, #7f82ac); } -.point-of-sale #rightheader button.neworder-button { +.point-of-sale #rightheader button.square{ width: 32px; margin-left:4px; - margin-right:4px; } .point-of-sale div#order-selector { @@ -186,12 +185,20 @@ } .point-of-sale ol#orders { display: inline; + margin-left: 8px; } .point-of-sale li.order-selector-button { display: inline; } .point-of-sale li.selected-order button { font-weight: 900; + background: #7174A8 !important; + color: rgb(236, 237, 255) !important; + text-shadow: 0px 1px rgba(0, 0, 0, 0.31); + -webkit-box-shadow: 0px 1px 2px rgb(63, 66, 139) inset; + -moz-box-shadow: 0px 1px 2px rgb(63, 66, 139) inset; + -ms-box-shadow: 0px 1px 2px rgb(63, 66, 139) inset; + box-shadow: 0px 1px 2px rgb(63, 66, 139) inset; } /* c) The session buttons */ diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index e4d69bca26f..cfaecf80a70 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -55,7 +55,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal 'selectedOrder': null, }); - this.get('orders').bind('remove', function(){ self.on_removed_order(); }); + this.get('orders').bind('remove', function(order,_unused_,options){ + self.on_removed_order(order,options.index,options.reason); + }); // We fetch the backend data on the server asynchronously. this is done only when the pos user interface is launched, // Any change on this data made on the server is thus not reflected on the point of sale until it is relaunched. @@ -239,11 +241,14 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal // this is called when an order is removed from the order collection. It ensures that there is always an existing // order and a valid selected order - on_removed_order: function(removed_order){ - if( this.get('orders').isEmpty()){ - this.add_new_order(); + on_removed_order: function(removed_order,index,reason){ + if(reason === 'abandon' && this.get('orders').size() > 0){ + // when we intentionally remove an unfinished order, and there is another existing one + this.set({'selectedOrder' : this.get('orders').at(index) || this.get('orders').last()}); }else{ - this.set({ selectedOrder: this.get('orders').last() }); + // when the order was automatically removed after completion, + // or when we intentionally delete the only concurrent order + this.add_new_order(); } }, @@ -254,6 +259,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.set('selectedOrder', order); }, + //removes the current order + delete_current_order: function(){ + this.get('selectedOrder').destroy({'reason':'abandon'}); + console.log('coucou!'); + }, + // saves the order locally and try to send it to the backend. // it returns a deferred that succeeds after having tried to send the order and all the other pending orders. push_order: function(order) { diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index bf7cf4d13af..dc00c995480 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -362,28 +362,23 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.order = options.order; this.order.bind('destroy',function(){ self.destroy(); }); this.order.bind('change', function(){ self.renderElement(); }); - this.pos.bind('change:selectedOrder', _.bind( function(pos) { - var selectedOrder; - selectedOrder = pos.get('selectedOrder'); - if (this.order === selectedOrder) { - this.setButtonSelected(); - } - }, this)); + this.pos.bind('change:selectedOrder', function() { + self.renderElement(); + }, this); }, renderElement:function(){ this._super(); this.$('button.select-order').off('click').click(_.bind(this.selectOrder, this)); this.$('button.close-order').off('click').click(_.bind(this.closeOrder, this)); + if( this.order === this.pos.get('selectedOrder') ){ + this.$el.addClass('selected-order'); + } }, selectOrder: function(event) { this.pos.set({ selectedOrder: this.order }); }, - setButtonSelected: function() { - $('.selected-order').removeClass('selected-order'); - this.$el.addClass('selected-order'); - }, closeOrder: function(event) { this.order.destroy(); }, @@ -848,6 +843,8 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.leftpane_width = '440px'; this.cashier_controls_visible = true; this.image_cache = new module.ImageCache(); // for faster products image display + + $('.oe_tooltip').remove(); // remove tooltip from the start session button }, start: function() { @@ -859,6 +856,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa self.$('.neworder-button').click(function(){ self.pos.add_new_order(); }); + + self.$('.deleteorder-button').click(function(){ + self.pos.delete_current_order(); + }); //when a new order is created, add an order button widget self.pos.get('orders').bind('add', function(new_order){ diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index e28ea1c06b0..67df69879ee 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -12,7 +12,8 @@
- + +
    From 84cd290018016a068a67a087d5409ff2af8bda1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 5 Sep 2013 15:31:59 +0200 Subject: [PATCH 02/14] [IMP] point_of_sale: remove hover effects, and change button colors when pressed instead (use :active) + tooltip removal was not always effective bzr revid: fva@openerp.com-20130905133159-8pu2kd8ex5tdbirl --- addons/point_of_sale/static/src/css/pos.css | 34 +++++++------------ addons/point_of_sale/static/src/js/widgets.js | 11 +++--- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 2294513a389..d78276b2b97 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -222,7 +222,7 @@ .point-of-sale #rightheader .header-button:last-child{ border-left: 1px solid #3a3a3a; } -.point-of-sale #rightheader .header-button:hover{ +.point-of-sale #rightheader .header-button:active{ background: rgba(0,0,0,0.2); text-shadow: #000 0px 0px 3px; color:#EEE; @@ -314,18 +314,10 @@ border-top: 1px solid #efefef; font-size: 14px; } -.point-of-sale #paypad button, .point-of-sale #numpad button, .point-of-sale .popup button{ - position: relative; - top: 0; - -webkit-transition: top 150ms linear; - -moz-transition: top 150ms linear; - -ms-transition: top 150ms linear; - transition: top 150ms linear; -} -.point-of-sale #paypad button:active, .point-of-sale #numpad button:active, .point-of-sale .popup button:active{ - top:3px; -} -.point-of-sale #paypad button:hover, .point-of-sale #numpad button:hover, .point-of-sale #numpad .selected-mode, .point-of-sale .popup button:hover { +.point-of-sale #paypad button:active, +.point-of-sale #numpad button:active, +.point-of-sale #numpad .selected-mode, +.point-of-sale .popup button:active{ border: none; color: white; background: #7f82ac; @@ -525,7 +517,7 @@ -moz-box-shadow: 0px 2px 2px rgba(0,0,0, 0.1); box-shadow: 0px 2px 2px rgba(0,0,0, 0.1); } -.point-of-sale .category-simple-button:hover { +.point-of-sale .category-simple-button:active{ color: white; background: #7f82ac; border: 1px solid #7f82ac; @@ -1056,13 +1048,13 @@ -moz-transition: background 250ms ease-in-out; transition: background 250ms ease-in-out; } -.point-of-sale .order .orderline:hover{ +.point-of-sale .order .orderline:active{ background: rgba(140,143,183,0.05); -webkit-transition: background 50ms ease-in-out; -moz-transition: background 50ms ease-in-out; transition: background 50ms ease-in-out; } -.point-of-sale .order .orderline.empty:hover{ +.point-of-sale .order .orderline.empty:active{ background: transparent; cursor: default; } @@ -1163,7 +1155,7 @@ .point-of-sale .pos-actionbar .button .icon{ margin-top: 10px; } -.point-of-sale .pos-actionbar .button:hover { +.point-of-sale .pos-actionbar .button:active{ color: white; background: #7f82ac; border: 1px solid #7f82ac; @@ -1180,7 +1172,7 @@ .point-of-sale .pos-actionbar .button.disabled *{ opacity: 0.5; } -.point-of-sale .pos-actionbar .button.disabled:hover{ +.point-of-sale .pos-actionbar .button.disabled:active{ border: 1px solid #cacaca; border-radius: 4px; color: #555; @@ -1249,7 +1241,7 @@ display: block; cursor:pointer; } -.point-of-sale .debug-widget .button:hover{ +.point-of-sale .debug-widget .button:active{ background: rgba(96,21,177,0.45); } .point-of-sale .debug-widget input{ @@ -1337,7 +1329,7 @@ -moz-box-shadow: 0px 2px 2px rgba(0,0,0, 0.3); box-shadow: 0px 2px 2px rgba(0,0,0, 0.3); } -.point-of-sale .popup .button:hover { +.point-of-sale .popup .button:active{ color: white; background: #7f82ac; border: 1px solid #7f82ac; @@ -1405,7 +1397,7 @@ -moz-transition: all 250ms ease-in-out; transition: all 250ms ease-in-out; } -.point-of-sale .scrollbar .button:hover{ +.point-of-sale .scrollbar .button:active{ text-shadow: rgba(255,255,255,0.8) 0px 0px 15px; } .point-of-sale .scrollbar .button.disabled{ diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index dc00c995480..c67bb609a96 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -62,10 +62,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa start: function() { this.state.bind('change:mode', this.changedMode, this); this.changedMode(); - this.$el.find('button#numpad-backspace').click(_.bind(this.clickDeleteLastChar, this)); - this.$el.find('button#numpad-minus').click(_.bind(this.clickSwitchSign, this)); - this.$el.find('button.number-char').click(_.bind(this.clickAppendNewChar, this)); - this.$el.find('button.mode-button').click(_.bind(this.clickChangeMode, this)); + this.$el.find('.numpad-backspace').click(_.bind(this.clickDeleteLastChar, this)); + this.$el.find('.numpad-minus').click(_.bind(this.clickSwitchSign, this)); + this.$el.find('.number-char').click(_.bind(this.clickAppendNewChar, this)); + this.$el.find('.mode-button').click(_.bind(this.clickChangeMode, this)); }, clickDeleteLastChar: function() { return this.state.deleteLastChar(); @@ -844,12 +844,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.cashier_controls_visible = true; this.image_cache = new module.ImageCache(); // for faster products image display - $('.oe_tooltip').remove(); // remove tooltip from the start session button }, start: function() { var self = this; return self.pos.ready.done(function() { + $('.oe_tooltip').remove(); // remove tooltip from the start session button + self.build_currency_template(); self.renderElement(); From 3443f6cd9e01dd386e24607f70858dbd829c53a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 5 Sep 2013 15:38:31 +0200 Subject: [PATCH 03/14] [IMP] point_of_sale: forgot a few changes related to previous commit bzr revid: fva@openerp.com-20130905133831-5nwuy2njplvekd2y --- addons/point_of_sale/static/src/xml/pos.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 67df69879ee..9794b989b65 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -94,10 +94,10 @@
    - + -
    From 74a550dae851217e8f17fd99b29a7e150e28776f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 5 Sep 2013 15:42:17 +0200 Subject: [PATCH 04/14] [IMP] point_of_sale: this line doesn't make any sense and should never have been committed bzr revid: fva@openerp.com-20130905134217-2ij45szmu4tzsqiw --- addons/point_of_sale/static/src/js/widgets.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index c67bb609a96..8afd3df6255 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -189,8 +189,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa }else if( mode === 'price'){ order.getSelectedLine().set_unit_price(val); } - } else { - this.pos.get('selectedOrder').destroy(); } }, change_selected_order: function() { From 945376a0665618e14e880ed4e627822b17a31966 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 6 Sep 2013 15:53:31 +0200 Subject: [PATCH 05/14] [FIX] no Logger.getChild in Python 2.6 bzr revid: xmo@openerp.com-20130906135331-zt3uzoeupvlba513 --- openerp/tools/mail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 4581d69c6ef..7895f2c7192 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -49,7 +49,7 @@ def html_sanitize(src, silent=True): return src src = ustr(src, errors='replace') - logger = _logger.getChild('html_sanitize') + logger = logging.getLogger(__name__ + '.html_sanitize') # html encode email tags part = re.compile(r"(<(([^a<>]|a[^<>\s])[^<>]*)@[^<>]+>)", re.IGNORECASE | re.DOTALL) From 6da5da7aa00b9fdb84e8133944980dd981b0fc0d Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 6 Sep 2013 16:37:19 +0200 Subject: [PATCH 06/14] [FIX] activate import by default bzr revid: al@openerp.com-20130906143719-rl1vqf06p6f3o2na --- addons/base_import/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_import/__openerp__.py b/addons/base_import/__openerp__.py index eb8b4561c7e..e044930a242 100644 --- a/addons/base_import/__openerp__.py +++ b/addons/base_import/__openerp__.py @@ -26,7 +26,7 @@ Re-implement openerp's file import system: 'author': 'OpenERP SA', 'depends': ['web'], 'installable': True, - 'auto_install': False, + 'auto_install': True, 'data': [ 'security/ir.model.access.csv', ], From 4a1d3f16ce06b0b09717626c729d36c65b5d7c43 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 6 Sep 2013 17:01:01 +0200 Subject: [PATCH 07/14] [FIX] broken pager Turns out when code looks somewhat odd there may well be a good reason for it, and changing it without wondering breaks the pager. In this case, `/web/dataset/search_read` has a significant difference with Model.search_read: it returns the records slice specified by (``limit``, ``offset``) but it also returns the *total number of records* for ``domain`` which is sort-of useful to generating the pager. lp bug: https://launchpad.net/bugs/1218266 fixed bzr revid: xmo@openerp.com-20130906150101-2qb349fzaz6rye36 --- addons/web/static/src/js/data.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 26807a2ee0f..a4fbb364a21 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -61,18 +61,19 @@ instance.web.Query = instance.web.Class.extend({ }, _execute: function () { var self = this; - return this._model.call('search_read', { + return instance.session.rpc('/web/dataset/search_read', { + model: this._model.name, + fields: this._fields || false, domain: instance.web.pyeval.eval('domains', [this._model.domain(this._filter)]), - fields: this._fields || false, - offset: this._offset, - limit: this._limit, - order: instance.web.serialize_sort(this._order_by), context: instance.web.pyeval.eval('contexts', [this._model.context(this._context)]), + offset: this._offset, + limit: this._limit, + sort: instance.web.serialize_sort(this._order_by) }).then(function (results) { self._count = results.length; - return results; + return results.records; }, null); }, /** From 44967200e4a5a6b1748c25d4e6044e8492fbdb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Fri, 6 Sep 2013 17:34:48 +0200 Subject: [PATCH 08/14] [IMP] point_of_sale: removed the ScaleInvite Screen in cashier mode, + only update the weight value in ScaleScreen bzr revid: fva@openerp.com-20130906153448-daev4x2ea3rf4pug --- addons/point_of_sale/static/src/js/devices.js | 23 +++++++++++----- addons/point_of_sale/static/src/js/screens.js | 27 ++++++++++--------- addons/point_of_sale/static/src/xml/pos.xml | 5 ++-- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index 9a74eec0c05..7e847abdc32 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -84,10 +84,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal weighting_start: function(){ if(!this.weighting){ this.weighting = true; - if(!this.bypass_proxy){ - this.weight = 0; - return this.message('weighting_start'); - } + this.weight = 0; + return this.message('weighting_start'); + }else{ + console.error('Weighting already started!!!'); + this.weight = 0; } }, @@ -96,6 +97,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal // and a weighting_end() weighting_read_kg: function(){ var self = this; + if(!this.weighting){ + console.error('Weighting while not started!!!'); + } this.message('weighting_read_kg',{}) .done(function(weight){ if(self.weighting){ @@ -123,9 +127,14 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal // the client has finished weighting products weighting_end: function(){ - this.weight = 0; - this.weighting = false; - this.message('weighting_end'); + if(this.weighting){ + this.weight = 0; + this.weighting = false; + this.message('weighting_end'); + }else{ + console.error('Weighting already ended !!!'); + this.weight = 0; + } }, // the pos asks the client to pay 'price' units diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 8c588adadf3..f8bf0df1590 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -271,19 +271,19 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }); var self = this; - var cashier_mode = this.pos_widget.screen_selector.get_user_mode() === 'cashier'; + this.cashier_mode = this.pos_widget.screen_selector.get_user_mode() === 'cashier'; - this.pos_widget.set_numpad_visible(this.show_numpad && cashier_mode); + this.pos_widget.set_numpad_visible(this.show_numpad && this.cashier_mode); this.pos_widget.set_leftpane_visible(this.show_leftpane); - this.pos_widget.set_left_action_bar_visible(this.show_leftpane && !cashier_mode); - this.pos_widget.set_cashier_controls_visible(cashier_mode); + this.pos_widget.set_left_action_bar_visible(this.show_leftpane && !this.cashier_mode); + this.pos_widget.set_cashier_controls_visible(this.cashier_mode); - if(cashier_mode && this.pos.iface_self_checkout){ + if(this.cashier_mode && this.pos.iface_self_checkout){ this.pos_widget.client_button.show(); }else{ this.pos_widget.client_button.hide(); } - if(cashier_mode){ + if(this.cashier_mode){ this.pos_widget.close_button.show(); }else{ this.pos_widget.close_button.hide(); @@ -460,7 +460,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa clearInterval(this.intervalID); self.pos_widget.screen_selector.set_current_screen(self.next_screen); } - },100); + },50); this.add_action_button({ label: _t('Back'), @@ -512,9 +512,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa var weight = self.pos.proxy.weighting_read_kg(); if(weight != self.weight){ self.weight = weight; - self.renderElement(); + self.$('.js-weight').text(self.get_product_weight_string()); } - },100); + },50); }, renderElement: function(){ var self = this; @@ -544,8 +544,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa var product = this.get_product(); return (product ? product.get('price') : 0) || 0; }, - get_product_weight: function(){ - return this.weight || 0; + get_product_weight_string: function(){ + return (this.weight || 0).toFixed(3) + ' Kg'; }, close: function(){ this._super(); @@ -740,7 +740,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ProductScreenWidget = module.ScreenWidget.extend({ template:'ProductScreenWidget', - scale_screen: 'scale_invite', + scale_screen: 'scale', + client_scale_screen : 'scale_invite', client_next_screen: 'client_payment', show_numpad: true, @@ -754,7 +755,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.product_list_widget = new module.ProductListWidget(this,{ click_product_action: function(product){ if(product.get('to_weight') && self.pos.iface_electronic_scale){ - self.pos_widget.screen_selector.set_current_screen(self.scale_screen, {product: product}); + self.pos_widget.screen_selector.set_current_screen( self.cashier_mode ? self.scale_screen : self.client_scale_screen, {product: product}); }else{ self.pos.get('selectedOrder').addProduct(product); } diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 9794b989b65..5c5faf3fc82 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -192,8 +192,9 @@

    - - Kg + + +

    From a382a62555c7b3527dbafb096bfd602a938a8a61 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 6 Sep 2013 17:44:22 +0200 Subject: [PATCH 09/14] [FIX] Revert data.js test that was not reverted along with the corresponding patch in previous commit See also reverted commit revid:nicolas.vanhoren@openerp.com-20130805130458-21w806v9wc456oq4 bzr revid: odo@openerp.com-20130906154422-jkdf2v2stgcd6akx --- addons/web/static/test/data.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/test/data.js b/addons/web/static/test/data.js index bddf698ede9..d7a957ad920 100644 --- a/addons/web/static/test/data.js +++ b/addons/web/static/test/data.js @@ -18,16 +18,16 @@ openerp.testing.section('data.model.group_by', { "should have single grouping field"); return group_result; }); - mock('foo:search_read', function (args, kwargs) { - deepEqual(kwargs.domain, [['bar', '=', 3]], + mock('/web/dataset/search_read', function (args) { + deepEqual(args.params.domain, [['bar', '=', 3]], "should have domain matching that of group_by result"); - return [ + return {records: [ {bar: 3, id: 1}, {bar: 3, id: 2}, {bar: 3, id: 4}, {bar: 3, id: 8}, {bar: 3, id: 16} - ]; + ], length: 5}; }); return m.query().group_by('bar') From dfb9d317f269810c8e857a7bc898389242ac9fa7 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Mon, 9 Sep 2013 12:55:23 +0200 Subject: [PATCH 10/14] [MERGE] data file loading refactoring, ready for code autoreload bzr revid: al@openerp.com-20130909105523-jkffhy5gr34k25hr --- openerp/modules/loading.py | 68 +++++++++++++++----------------------- openerp/tools/convert.py | 28 ++++++++++++++++ 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 52ca356ffd8..c288671a7e1 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -56,19 +56,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= :param skip_modules: optional list of module names (packages) which have previously been loaded and can be skipped :return: list of modules that were installed or updated """ - def process_sql_file(cr, fp): - queries = fp.read().split(';') - for query in queries: - new_query = ' '.join(query.split()) - if new_query: - cr.execute(new_query) - - load_init_xml = lambda *args: _load_data(cr, *args, kind='init_xml') - load_update_xml = lambda *args: _load_data(cr, *args, kind='update_xml') - load_demo_xml = lambda *args: _load_data(cr, *args, kind='demo_xml') - load_data = lambda *args: _load_data(cr, *args, kind='data') - load_demo = lambda *args: _load_data(cr, *args, kind='demo') - def load_test(module_name, idref, mode): cr.commit() try: @@ -86,6 +73,28 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= else: cr.rollback() + def _get_files_of_kind(kind): + if kind == 'demo': + kind = ['demo_xml', 'demo'] + elif kind == 'data': + kind = ['init_xml', 'update_xml', 'data'] + if isinstance(kind, str): + kind = [kind] + files = [] + for k in kind: + for f in package.data[k]: + files.append(f) + if k.endswith('_xml') and not (k == 'init_xml' and not f.endswith('.xml')): + # init_xml, update_xml and demo_xml are deprecated except + # for the case of init_xml with yaml, csv and sql files as + # we can't specify noupdate for those file. + correct_key = 'demo' if k.count('demo') else 'data' + _logger.warning( + "module %s: key '%s' is deprecated in favor of '%s' for file '%s'.", + package.name, k, correct_key, f + ) + return files + def _load_data(cr, module_name, idref, mode, kind): """ @@ -95,32 +104,12 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= init mode. """ - for filename in package.data[kind]: + for filename in _get_files_of_kind(kind): _logger.info("module %s: loading %s", module_name, filename) - _, ext = os.path.splitext(filename) - pathname = os.path.join(module_name, filename) - fp = tools.file_open(pathname) noupdate = False - if kind in ('demo', 'demo_xml'): + if kind in ('demo', 'demo_xml') or (filename.endswith('.csv') and kind in ('init', 'init_xml')): noupdate = True - try: - ext = ext.lower() - if ext == '.csv': - if kind in ('init', 'init_xml'): - noupdate = True - tools.convert_csv_import(cr, module_name, pathname, fp.read(), idref, mode, noupdate) - elif ext == '.sql': - process_sql_file(cr, fp) - elif ext == '.yml': - tools.convert_yaml_import(cr, module_name, fp, kind, idref, mode, noupdate, report) - elif ext == '.xml': - tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report) - elif ext == '.js': - pass # .js files are valid but ignored here. - else: - _logger.warning("Can't load unknown file type %s.", filename) - finally: - fp.close() + tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report) if status is None: status = {} @@ -176,13 +165,10 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= if package.state=='to upgrade': # upgrading the module information modobj.write(cr, SUPERUSER_ID, [module_id], modobj.get_values_from_terp(package.data)) - load_init_xml(module_name, idref, mode) - load_update_xml(module_name, idref, mode) - load_data(module_name, idref, mode) + _load_data(cr, module_name, idref, mode, kind='data') if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'): status['progress'] = (index + 0.75) / len(graph) - load_demo_xml(module_name, idref, mode) - load_demo(module_name, idref, mode) + _load_data(cr, module_name, idref, mode, kind='demo') cr.execute('update ir_module_module set demo=%s where id=%s', (True, module_id)) # launch tests only in demo mode, as most tests will depend diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index 616abb23fa7..47f75e43fe8 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -33,6 +33,7 @@ import time import openerp import openerp.release import openerp.workflow +from yaml_import import convert_yaml_import import assertion_report @@ -877,6 +878,33 @@ form: module.record_id""" % (xml_id,) 'url': self._tag_url } +def convert_file(cr, module, filename, idref, mode='update', noupdate=False, kind=None, report=None): + pathname = os.path.join(module, filename) + fp = misc.file_open(pathname) + ext = os.path.splitext(filename)[1].lower() + try: + if ext == '.csv': + convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate) + elif ext == '.sql': + convert_sql_import(cr, fp) + elif ext == '.yml': + convert_yaml_import(cr, module, fp, kind, idref, mode, noupdate, report) + elif ext == '.xml': + convert_xml_import(cr, module, fp, idref, mode, noupdate, report) + elif ext == '.js': + pass # .js files are valid but ignored here. + else: + _logger.warning("Can't load unknown file type %s.", filename) + finally: + fp.close() + +def convert_sql_import(cr, fp): + queries = fp.read().split(';') + for query in queries: + new_query = ' '.join(query.split()) + if new_query: + cr.execute(new_query) + def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', noupdate=False): '''Import csv file : From f58b15af482a21d5a79019f7d8dcf7235a19ea55 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 9 Sep 2013 13:03:30 +0200 Subject: [PATCH 11/14] [IMP] Remove deprecated manifest keys bzr revid: fme@openerp.com-20130909110330-kl71n1km00gew1oo --- addons/base_gengo/__openerp__.py | 8 ++++---- addons/base_gengo/gengo_sync_schedular_data.xml | 2 +- addons/l10n_et/__openerp__.py | 6 +++--- addons/l10n_in_hr_payroll/__openerp__.py | 5 ++--- addons/l10n_pt/__openerp__.py | 6 +++--- addons/sale_stock/__openerp__.py | 6 +++--- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/addons/base_gengo/__openerp__.py b/addons/base_gengo/__openerp__.py index aa1be78321f..1a409f9a47c 100644 --- a/addons/base_gengo/__openerp__.py +++ b/addons/base_gengo/__openerp__.py @@ -36,13 +36,13 @@ This wizard will activate the CRON job and the Scheduler and will start the auto 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', 'depends': ['base'], - 'init_xml': ['gengo_sync_schedular_data.xml'], - 'update_xml': [ + 'data': [ + 'gengo_sync_schedular_data.xml' 'ir_translation.xml', 'res_company_view.xml', 'wizard/base_gengo_translations_view.xml', - ], - 'demo_xml': [], + ], + 'demo': [], 'test': [], 'installable': True, 'auto_install': False, diff --git a/addons/base_gengo/gengo_sync_schedular_data.xml b/addons/base_gengo/gengo_sync_schedular_data.xml index 823ca8f14db..baf2a639cff 100644 --- a/addons/base_gengo/gengo_sync_schedular_data.xml +++ b/addons/base_gengo/gengo_sync_schedular_data.xml @@ -1,6 +1,6 @@ - + Gengo Sync Translation (Response) diff --git a/addons/l10n_et/__openerp__.py b/addons/l10n_et/__openerp__.py index f788e9c52d5..fa093b0b855 100644 --- a/addons/l10n_et/__openerp__.py +++ b/addons/l10n_et/__openerp__.py @@ -47,13 +47,13 @@ This is the latest Ethiopian OpenERP localization and consists of: 'data/account.tax.template.csv', 'data/res.country.state.csv', ], - 'update_xml': [ + 'data': [ 'l10n_et_wizard.xml', ], 'test': [ ], - 'demo_xml': [ + 'demo': [ ], 'installable': True, 'active': False, -} \ No newline at end of file +} diff --git a/addons/l10n_in_hr_payroll/__openerp__.py b/addons/l10n_in_hr_payroll/__openerp__.py index 6d891c7a08e..2522d543548 100644 --- a/addons/l10n_in_hr_payroll/__openerp__.py +++ b/addons/l10n_in_hr_payroll/__openerp__.py @@ -21,7 +21,6 @@ { 'name': 'Indian Payroll', 'category': 'Localization', - 'init_xml': [], 'author': 'OpenERP SA', 'website':'http://www.openerp.com', 'depends': ['hr_payroll'], @@ -43,7 +42,7 @@ Indian Payroll Salary Rules. - Yearly Salary by Head and Yearly Salary by Employee Report """, 'active': False, - 'update_xml': [ + 'data': [ 'l10n_in_hr_payroll_view.xml', 'data/l10n_in_hr_payroll_data.xml', 'data/hr.salary.rule.csv', @@ -61,7 +60,7 @@ Indian Payroll Salary Rules. 'test/payment_advice_batch.yml' ], - 'demo_xml': ['l10n_in_hr_payroll_demo.xml'], + 'demo': ['l10n_in_hr_payroll_demo.xml'], 'installable': True } diff --git a/addons/l10n_pt/__openerp__.py b/addons/l10n_pt/__openerp__.py index 03e3b0e9baa..978c3efc91e 100644 --- a/addons/l10n_pt/__openerp__.py +++ b/addons/l10n_pt/__openerp__.py @@ -33,8 +33,8 @@ 'account', 'account_chart', ], - 'init_xml': [], - 'update_xml': ['account_types.xml', + 'data': [ + 'account_types.xml', 'account_chart.xml', 'account_tax_code_template.xml', 'account_chart_template.xml', @@ -42,7 +42,7 @@ 'account_taxes.xml', 'l10n_chart_pt_wizard.xml', ], - 'demo_xml': [], + 'demo': [], 'installable': True, } diff --git a/addons/sale_stock/__openerp__.py b/addons/sale_stock/__openerp__.py index fd20748aa75..f68db56ea2f 100644 --- a/addons/sale_stock/__openerp__.py +++ b/addons/sale_stock/__openerp__.py @@ -46,8 +46,8 @@ You can choose flexible invoicing methods: 'website': 'http://www.openerp.com', 'images': ['images/deliveries_to_invoice.jpeg'], 'depends': ['sale', 'stock', 'procurement'], - 'init_xml': [], - 'update_xml': ['security/sale_stock_security.xml', + 'data': [ + 'security/sale_stock_security.xml', 'security/ir.model.access.csv', 'company_view.xml', 'sale_stock_view.xml', @@ -57,7 +57,7 @@ You can choose flexible invoicing methods: 'report/sale_report_view.xml', 'process/sale_stock_process.xml', ], - 'demo_xml': ['sale_stock_demo.xml'], + 'demo': ['sale_stock_demo.xml'], 'test': ['test/cancel_order_sale_stock.yml', 'test/picking_order_policy.yml', 'test/prepaid_order_policy.yml', From 1a1b8ca6fdba825fe6c5ad401792e2783fdc5215 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 9 Sep 2013 13:32:29 +0200 Subject: [PATCH 12/14] [FIX] manifest error bzr revid: fme@openerp.com-20130909113229-c3544qhirlpi45ee --- addons/base_gengo/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_gengo/__openerp__.py b/addons/base_gengo/__openerp__.py index 1a409f9a47c..3f1b5957fec 100644 --- a/addons/base_gengo/__openerp__.py +++ b/addons/base_gengo/__openerp__.py @@ -37,7 +37,7 @@ This wizard will activate the CRON job and the Scheduler and will start the auto 'website': 'http://www.openerp.com', 'depends': ['base'], 'data': [ - 'gengo_sync_schedular_data.xml' + 'gengo_sync_schedular_data.xml', 'ir_translation.xml', 'res_company_view.xml', 'wizard/base_gengo_translations_view.xml', From b38c27103158a751e408994c6d0e0cc03df1bf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 11 Sep 2013 17:41:55 +0200 Subject: [PATCH 13/14] [IMP] point_of_sale: big reworking of the scale screens: - no welcome scale in cashier mode, as it was an unnecessary delay for people who use it all day - no more parallel calls to the proxy which could reorder or make the driver crash - auto throttling of the proxy calls -> max 20 reads per seconds, but can go slower as well. - faster and cleaner update of the weight in the scale screen bzr revid: fva@openerp.com-20130911154155-rs600cixvftvkhoi --- addons/point_of_sale/controllers/main.py | 39 ++++- addons/point_of_sale/static/src/js/devices.js | 138 +++++++++++++----- addons/point_of_sale/static/src/js/models.js | 1 + addons/point_of_sale/static/src/js/screens.js | 103 ++++++------- 4 files changed, 179 insertions(+), 102 deletions(-) diff --git a/addons/point_of_sale/controllers/main.py b/addons/point_of_sale/controllers/main.py index db5d5a25018..e0bd19545a6 100644 --- a/addons/point_of_sale/controllers/main.py +++ b/addons/point_of_sale/controllers/main.py @@ -3,12 +3,17 @@ import logging import simplejson import os import openerp +import time +import random from openerp.addons.web import http from openerp.addons.web.http import request from openerp.addons.web.controllers.main import manifest_list, module_boot, html_template class PointOfSaleController(http.Controller): + def __init__(self): + self.scale = 'closed' + self.scale_weight = 0.0 @http.route('/pos/app', type='http', auth='admin') def app(self): @@ -64,6 +69,10 @@ class PointOfSaleController(http.Controller): return m + @http.route('/pos/test_connection', type='json', auth='admin') + def test_connection(self): + return + @http.route('/pos/scan_item_success', type='json', auth='admin') def scan_item_success(self, ean): """ @@ -98,18 +107,38 @@ class PointOfSaleController(http.Controller): @http.route('/pos/weighting_start', type='json', auth='admin') def weighting_start(self): - print "weighting_start" + if self.scale == 'closed': + print "Opening (Fake) Connection to Scale..." + self.scale = 'open' + self.scale_weight = 0.0 + time.sleep(0.1) + print "... Scale Open." + else: + print "WARNING: Scale already Connected !!!" return @http.route('/pos/weighting_read_kg', type='json', auth='admin') def weighting_read_kg(self): - print "weighting_read_kg" - return 3.14 + if self.scale == 'open': + print "Reading Scale..." + time.sleep(0.025) + self.scale_weight += 0.01 + print "... Done." + return self.scale_weight + else: + print "WARNING: Reading closed scale !!!" + return 0.0 @http.route('/pos/weighting_end', type='json', auth='admin') def weighting_end(self): - print "weighting_end" - return + if self.scale == 'open': + print "Closing Connection to Scale ..." + self.scale = 'closed' + self.scale_weight = 0.0 + time.sleep(0.1) + print "... Scale Closed." + else: + print "WARNING: Scale already Closed !!!" @http.route('/pos/payment_request', type='json', auth='admin') def payment_request(self, price): diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index 7e847abdc32..2be9cb74da2 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -1,6 +1,81 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sale + // the JobQueue schedules a sequence of 'jobs'. each job is + // a function returning a deferred. the queue waits for each job to finish + // before launching the next. Each job can also be scheduled with a delay. + // the is used to prevent parallel requests to the proxy. + + module.JobQueue = function(){ + var queue = []; + var running = false; + var scheduled_end_time = 0; + var end_of_queue = (new $.Deferred()).resolve(); + var stoprepeat = false; + + var run = function(){ + if(end_of_queue.state() === 'resolved'){ + end_of_queue = new $.Deferred(); + } + if(queue.length > 0){ + running = true; + var job = queue[0]; + if(!job.opts.repeat || stoprepeat){ + queue.shift(); + stoprepeat = false; + } + + // the time scheduled for this job + scheduled_end_time = (new Date()).getTime() + (job.opts.duration || 0); + + // we run the job and put in def when it finishes + var def = job.fun() || (new $.Deferred()).resolve(); + + // we don't care if a job fails ... + def.always(function(){ + // we run the next job after the scheduled_end_time, even if it finishes before + setTimeout(function(){ + run(); + }, Math.max(0, scheduled_end_time - (new Date()).getTime()) ); + }); + }else{ + running = false; + end_of_queue.resolve(); + } + }; + + // adds a job to the schedule. + // opts : { + // duration : the job is guaranteed to finish no quicker than this (milisec) + // repeat : if true, the job will be endlessly repeated + // important : if true, the scheduled job cannot be canceled by a queue.clear() + // } + this.schedule = function(fun, opts){ + queue.push({fun:fun, opts:opts || {}}); + if(!running){ + run(); + } + } + + // remove all jobs from the schedule (except the ones marked as important) + this.clear = function(){ + queue = _.filter(queue,function(job){job.opts.important === true}); + }; + + // end the repetition of the current job + this.stoprepeat = function(){ + stoprepeat = true; + }; + + // returns a deferred that resolves when all scheduled + // jobs have been run. + // ( jobs added after the call to this method are considered as well ) + this.finished = function(){ + return end_of_queue; + } + + }; + // this object interfaces with the local proxy to communicate to the various hardware devices // connected to the Point of Sale. As the communication only goes from the POS to the proxy, // methods are used both to signal an event, and to fetch information. @@ -10,7 +85,6 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal options = options || {}; url = options.url || 'http://localhost:8069'; - this.weight = 0; this.weighting = false; this.debug_weight = 0; this.use_debug_weight = false; @@ -35,18 +109,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.connection.destroy(); }, message : function(name,params){ - var ret = new $.Deferred(); var callbacks = this.notifications[name] || []; for(var i = 0; i < callbacks.length; i++){ callbacks[i](params); } - - this.connection.rpc('/pos/' + name, params || {}).done(function(result) { - ret.resolve(result); - }).fail(function(error) { - ret.reject(error); - }); - return ret; + return this.connection.rpc('/pos/' + name, params || {}); }, // this allows the client to be notified when a proxy call is made. The notification @@ -82,14 +149,32 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal //the client is starting to weight weighting_start: function(){ + var ret = new $.Deferred(); if(!this.weighting){ this.weighting = true; - this.weight = 0; - return this.message('weighting_start'); + this.message('weighting_start').always(function(){ + ret.resolve(); + }); }else{ console.error('Weighting already started!!!'); - this.weight = 0; + ret.resolve(); } + return ret; + }, + + // the client has finished weighting products + weighting_end: function(){ + var ret = new $.Deferred(); + if(this.weighting){ + this.weighting = false; + this.message('weighting_end').always(function(){ + ret.resolve(); + }); + }else{ + console.error('Weighting already ended !!!'); + ret.resolve(); + } + return ret; }, //returns the weight on the scale. @@ -97,20 +182,14 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal // and a weighting_end() weighting_read_kg: function(){ var self = this; - if(!this.weighting){ - console.error('Weighting while not started!!!'); - } + var ret = new $.Deferred(); this.message('weighting_read_kg',{}) - .done(function(weight){ - if(self.weighting){ - if(self.use_debug_weight){ - self.weight = self.debug_weight; - }else{ - self.weight = weight; - } - } + .then(function(weight){ + ret.resolve(self.use_debug_weight ? self.debug_weight : weight); + }, function(){ //failed to read weight + ret.resolve(self.use_debug_weight ? self.debug_weight : 0.0); }); - return this.weight; + return ret; }, // sets a custom weight, ignoring the proxy returned value. @@ -125,17 +204,6 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.debug_weight = 0; }, - // the client has finished weighting products - weighting_end: function(){ - if(this.weighting){ - this.weight = 0; - this.weighting = false; - this.message('weighting_end'); - }else{ - console.error('Weighting already ended !!!'); - this.weight = 0; - } - }, // the pos asks the client to pay 'price' units payment_request: function(price){ diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index cfaecf80a70..fbbb15af9c7 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -24,6 +24,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.barcode_reader = new module.BarcodeReader({'pos': this}); // used to read barcodes this.proxy = new module.ProxyDevice(); // used to communicate to the hardware devices via a local proxy + this.proxy_queue = new module.JobQueue(); // used to prevent parallels communications to the proxy this.db = new module.PosLS(); // a database used to store the products and categories this.db.clear('products','categories'); this.debug = jQuery.deparam(jQuery.param.querystring()).debug !== undefined; //debug mode diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index f8bf0df1590..854c1e1adec 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -441,7 +441,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ErrorInvoiceTransferPopupWidget = module.ErrorPopupWidget.extend({ template: 'ErrorInvoiceTransferPopupWidget', }); - + module.ScaleInviteScreenWidget = module.ScreenWidget.extend({ template:'ScaleInviteScreenWidget', @@ -451,30 +451,35 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa show: function(){ this._super(); var self = this; + var queue = this.pos.proxy_queue; - self.pos.proxy.weighting_start(); - - this.intervalID = setInterval(function(){ - var weight = self.pos.proxy.weighting_read_kg(); - if(weight > 0.001){ - clearInterval(this.intervalID); - self.pos_widget.screen_selector.set_current_screen(self.next_screen); - } - },50); + queue.schedule(function(){ + return self.pos.proxy.weighting_start(); + },{ unclearable: true }); + + queue.schedule(function(){ + return self.pos.proxy.weighting_read_kg().then(function(weight){ + if(weight > 0.001){ + self.pos_widget.screen_selector.set_current_screen(self.next_screen); + } + }); + },{duration: 100, repeat: true}); this.add_action_button({ label: _t('Back'), icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ - clearInterval(this.intervalID); self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } }); }, close: function(){ this._super(); - clearInterval(this.intervalID); - this.pos.proxy.weighting_end(); + var self = this; + this.pos.proxy_queue.clear(); + this.pos.proxy_queue.schedule(function(){ + return self.pos.proxy.weighting_end(); + },{ unclearable: true }); }, }); @@ -486,9 +491,11 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa show: function(){ this._super(); - this.renderElement(); var self = this; + var queue = this.pos.proxy_queue; + this.set_weight(0); + this.renderElement(); this.add_action_button({ label: _t('Back'), @@ -507,14 +514,16 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, }); - this.pos.proxy.weighting_start(); - this.intervalID = setInterval(function(){ - var weight = self.pos.proxy.weighting_read_kg(); - if(weight != self.weight){ - self.weight = weight; - self.$('.js-weight').text(self.get_product_weight_string()); - } - },50); + queue.schedule(function(){ + return self.pos.proxy.weighting_start() + },{ unclearable: true }); + + queue.schedule(function(){ + return self.pos.proxy.weighting_read_kg().then(function(weight){ + self.set_weight(weight); + }); + },{duration:50, repeat: true}); + }, renderElement: function(){ var self = this; @@ -544,54 +553,24 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa var product = this.get_product(); return (product ? product.get('price') : 0) || 0; }, + set_weight: function(weight){ + this.weight = weight; + this.$('.js-weight').text(this.get_product_weight_string()); + }, get_product_weight_string: function(){ return (this.weight || 0).toFixed(3) + ' Kg'; }, close: function(){ + var self = this; this._super(); - clearInterval(this.intervalID); - this.pos.proxy.weighting_end(); + + this.pos.proxy_queue.clear(); + this.pos.proxy_queue.schedule(function(){ + self.pos.proxy.weighting_end(); + },{ unclearable: true }); }, }); - // the JobQueue schedules a sequence of 'jobs'. each job is - // a function returning a deferred. the queue waits for each job to finish - // before launching the next. Each job can also be scheduled with a delay. - // the queue jobqueue is used to prevent parallel requests to the payment terminal. - - module.JobQueue = function(){ - var queue = []; - var running = false; - var run = function(){ - if(queue.length > 0){ - running = true; - var job = queue.shift(); - setTimeout(function(){ - var def = job.fun(); - if(def){ - def.done(run); - }else{ - run(); - } - },job.delay || 0); - }else{ - running = false; - } - }; - - // adds a job to the schedule. - this.schedule = function(fun, delay){ - queue.push({fun:fun, delay:delay}); - if(!running){ - run(); - } - } - - // remove all jobs from the schedule - this.clear = function(){ - queue = []; - }; - }; module.ClientPaymentScreenWidget = module.ScreenWidget.extend({ template:'ClientPaymentScreenWidget', From 84e16c98951b8ae21b4f74f0724677d25061fca3 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 11 Sep 2013 18:15:29 +0200 Subject: [PATCH 14/14] [IMP] Added link to web training in web doc bzr revid: nicolas.vanhoren@openerp.com-20130911161529-ue0rqihlu02pr3qd --- addons/web/doc/index.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web/doc/index.rst b/addons/web/doc/index.rst index 650c12f55ec..35cd3b23afa 100644 --- a/addons/web/doc/index.rst +++ b/addons/web/doc/index.rst @@ -3,8 +3,12 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to OpenERP Web's documentation! -======================================= +OpenERP Web Reference Documentation +=================================== + +See also the `OpenERP Web Training`_. + +.. _OpenERP Web Training: https://doc.openerp.com/trunk/training/ Basics ------