From 5a8838243d62af2ed760a1a69a968d36ccbf1178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 30 Dec 2014 16:08:54 +0100 Subject: [WIP] point_of_sale, pos_restaurant: continued refactor - this time it's the restaurant module that has been refactored - the point of sale extensions points have been reviewed to be more constistent and allow conditional extensions. - the chrome subwidgets are instanciated before screens, so that screens can manipulate them if needed. --- addons/pos_restaurant/static/src/js/multiprint.js | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'addons/pos_restaurant/static/src/js/multiprint.js') diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js index c2d4461c3ae..0ca4695768b 100644 --- a/addons/pos_restaurant/static/src/js/multiprint.js +++ b/addons/pos_restaurant/static/src/js/multiprint.js @@ -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,39 +220,39 @@ 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); } }, }); -- cgit v1.2.3