From 82ae362aba27f6c1a66c4c0096e36e596b78d0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Sun, 1 Feb 2015 02:34:56 +0100 Subject: [PATCH] [IMP] pos_restaurant: allow temporarily skip some order lines when kitchen printing --- addons/point_of_sale/static/src/js/screens.js | 7 +- .../static/src/css/restaurant.css | 12 +++ .../static/src/js/multiprint.js | 82 +++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index e3e027bb50e..9bcf9cb89b4 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -400,8 +400,7 @@ openerp.point_of_sale.load_screens = function load_screens(instance, module){ // this.pos.bind('change:selectedOrder', this.change_selected_order, this); this.line_click_handler = function(event){ - self.pos.get_order().select_orderline(this.orderline); - self.numpad_state.reset(); + self.click_line(this.orderline, event); }; if (this.pos.get_order()) { @@ -409,6 +408,10 @@ openerp.point_of_sale.load_screens = function load_screens(instance, module){ // } }, + click_line: function(orderline, event) { + this.pos.get_order().select_orderline(orderline); + this.numpad_state.reset(); + }, set_value: function(val) { var order = this.pos.get_order(); if (order.get_selected_orderline()) { diff --git a/addons/pos_restaurant/static/src/css/restaurant.css b/addons/pos_restaurant/static/src/css/restaurant.css index 57d667670d8..7b2d0551284 100644 --- a/addons/pos_restaurant/static/src/css/restaurant.css +++ b/addons/pos_restaurant/static/src/css/restaurant.css @@ -274,6 +274,18 @@ .pos .order-button.floor-button .fa{ font-size: 24px; } +/* ------ ORDER LINE STATUS ------- */ + +.pos .order .orderline.dirty { + border-left: solid 6px #6EC89B; + color: #6EC89B; + padding-left: 9px; +} +.pos .order .orderline.skip { + border-left: solid 6px #7F82AC; + color: #7F82AC; + padding-left: 9px; +} /* ------ ORDER NOTES ------- */ diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js index fdb458c81a2..1b63efd8009 100644 --- a/addons/pos_restaurant/static/src/js/multiprint.js +++ b/addons/pos_restaurant/static/src/js/multiprint.js @@ -54,7 +54,58 @@ openerp.pos_restaurant.load_multiprint = function(instance,module){ }, }); + var _super_orderline = module.Orderline.prototype; module.Orderline = module.Orderline.extend({ + initialize: function(args) { + _super_orderline.initialize.apply(this,arguments); + if (typeof this.mp_dirty === 'undefined') { + // mp dirty is true if this orderline has changed + // since the last kitchen print + this.mp_dirty = true; + } + if (!this.mp_skip) { + // mp_skip is true if the cashier want this orderline + // not to be sent to the kitchen + this.mp_skip = false; + } + }, + init_from_JSON: function(json) { + _super_orderline.init_from_JSON.apply(this,arguments); + this.mp_dirty = json.mp_dirty; + this.mp_skip = json.mp_skip; + }, + export_as_JSON: function() { + var json = _super_orderline.export_as_JSON.apply(this,arguments); + json.mp_dirty = this.mp_dirty; + json.mp_skip = this.mp_skip; + return json; + }, + set_quantity: function(quantity) { + if (quantity !== this.quantity) { + this.mp_dirty = true; + } + _super_orderline.set_quantity.apply(this,arguments); + }, + can_be_merged_with: function(orderline) { + return (!this.mp_skip) && + (!orderline.mp_skip) && + _super_orderline.can_be_merged_with.apply(this,arguments); + }, + set_skip: function(skip) { + if (this.mp_dirty && skip && !this.mp_skip) { + this.mp_skip = true; + this.trigger('change',this); + } + if (this.mp_skip && !skip) { + this.mp_dirty = true; + this.mp_skip = false; + this.trigger('change',this); + } + }, + set_dirty: function(dirty) { + this.mp_dirty = dirty; + this.trigger('change',this); + }, get_line_diff_hash: function(){ if (this.get_note()) { return this.get_product().id + '|' + this.get_note(); @@ -64,11 +115,39 @@ openerp.pos_restaurant.load_multiprint = function(instance,module){ }, }); + module.OrderWidget.include({ + render_orderline: function(orderline) { + var node = this._super(orderline); + if (orderline.mp_skip) { + node.classList.add('skip'); + } else if (orderline.mp_dirty) { + node.classList.add('dirty'); + } + return node; + }, + click_line: function(line, event) { + if (this.pos.get_order().selected_orderline !== line) { + this.mp_dbclk_time = (new Date()).getTime(); + } else if (!this.mp_dbclk_time) { + this.mp_dbclk_time = (new Date()).getTime(); + } else if (this.mp_dbclk_time + 500 > (new Date()).getTime()) { + line.set_skip(!line.mp_skip); + this.mp_dbclk_time = 0; + } else { + this.mp_dbclk_time = (new Date()).getTime(); + } + this._super(line, event); + }, + }); + var _super_order = module.Order.prototype; module.Order = module.Order.extend({ build_line_resume: function(){ var resume = {}; this.orderlines.each(function(line){ + if (line.mp_skip) { + return; + } var line_hash = line.get_line_diff_hash(); var qty = Number(line.get_quantity()); var note = line.get_note(); @@ -85,6 +164,9 @@ openerp.pos_restaurant.load_multiprint = function(instance,module){ }, saveChanges: function(){ this.saved_resume = this.build_line_resume(); + this.orderlines.each(function(line){ + line.set_dirty(false); + }); this.trigger('change',this); }, computeChanges: function(categories){