diff options
| author | Frédéric van der Essen <fvdessen@gmail.com> | 2015-02-01 02:34:56 +0100 |
|---|---|---|
| committer | Frédéric van der Essen <fvdessen@gmail.com> | 2015-02-02 16:29:32 +0100 |
| commit | 82ae362aba27f6c1a66c4c0096e36e596b78d0f2 (patch) | |
| tree | 298f80ab89efe229ff83821eb7033159f5bd61c4 /addons/pos_restaurant/static/src/js | |
| parent | 3335a79e6b6de83c82c290b4591e89f8e6ca5742 (diff) | |
[IMP] pos_restaurant: allow temporarily skip some order lines when kitchen printing
Diffstat (limited to 'addons/pos_restaurant/static/src/js')
| -rw-r--r-- | addons/pos_restaurant/static/src/js/multiprint.js | 82 |
1 files changed, 82 insertions, 0 deletions
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){ |
