diff options
| author | Frédéric van der Essen <fvdessen@gmail.com> | 2014-12-31 15:37:47 +0100 |
|---|---|---|
| committer | Frédéric van der Essen <fvdessen@gmail.com> | 2014-12-31 15:37:47 +0100 |
| commit | b3cf5382a4829f03f55ee65933f51271c760ffaf (patch) | |
| tree | 2cff16b7f4ae85e31b98aaea8f1aa9f53e1fb24a /addons/pos_restaurant/static/src/js/multiprint.js | |
| parent | f15d84094db3bc7115eb68ebde946293d8a14600 (diff) | |
| parent | b1379c7173d5bb327c41d6accad0d70e0f8def71 (diff) | |
[MERGE] point_of_sale & co. : large js cleanup / refactor.
- See the branch's commit messages for details on the work done.
Diffstat (limited to 'addons/pos_restaurant/static/src/js/multiprint.js')
| -rw-r--r-- | addons/pos_restaurant/static/src/js/multiprint.js | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js index c2d4461c3ae..61b8c1663a4 100644 --- a/addons/pos_restaurant/static/src/js/multiprint.js +++ b/addons/pos_restaurant/static/src/js/multiprint.js @@ -1,4 +1,4 @@ -function openerp_restaurant_multiprint(instance,module){ +openerp.pos_restaurant.load_multiprint = function(instance,module){ var QWeb = instance.web.qweb; var _t = instance.web._t; @@ -33,7 +33,7 @@ function openerp_restaurant_multiprint(instance,module){ }, }); - module.PosModel.prototype.models.push({ + module.load_models({ model: 'restaurant.printer', fields: ['name','proxy_ip','product_categories_ids'], domain: null, @@ -220,41 +220,42 @@ function openerp_restaurant_multiprint(instance,module){ }, }); - module.PosWidget.include({ - build_widgets: function(){ - var self = this; - this._super(); - - if(this.pos.printers.length){ - var submitorder = $(QWeb.render('SubmitOrderButton')); - - submitorder.click(function(){ - var order = self.pos.get('selectedOrder'); - if(order.hasChangesToPrint()){ - order.printChanges(); - order.saveChanges(); - self.pos_widget.order_widget.update_summary(); - } - }); - - submitorder.appendTo(this.$('.control-buttons')); - this.$('.control-buttons').removeClass('oe_hidden'); + module.SubmitOrderButton = module.ActionButtonWidget.extend({ + 'template': 'SubmitOrderButton', + button_click: function(){ + var order = this.pos.get_order(); + if(order.hasChangesToPrint()){ + order.printChanges(); + order.saveChanges(); + } + }, + hilight: function(hi){ + if (hi) { + this.$el.addClass('highlight'); + } else { + this.$el.removeClass('highlight'); } }, - + }); + + module.define_action_button({ + 'name': 'submit_order', + 'widget': module.SubmitOrderButton, + 'condition': function() { + return this.pos.printers.length; + }, }); module.OrderWidget.include({ update_summary: function(){ this._super(); - var order = this.pos.get('selectedOrder'); - - if(order.hasChangesToPrint()){ - this.pos_widget.$('.order-submit').addClass('highlight'); - }else{ - this.pos_widget.$('.order-submit').removeClass('highlight'); + var changes = this.pos.get_order().hasChangesToPrint(); + if (this.getParent().action_buttons && + this.getParent().action_buttons.submit_order) { + this.getParent().action_buttons.submit_order.highlight(changes); } }, }); -} +}; + |
