summaryrefslogtreecommitdiff
path: root/addons/pos_restaurant/static/src/js/multiprint.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/pos_restaurant/static/src/js/multiprint.js')
-rw-r--r--addons/pos_restaurant/static/src/js/multiprint.js59
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);
}
},
});
-}
+};
+