[IMP] pos_restaurant: allow temporarily skip some order lines when kitchen printing

This commit is contained in:
Frédéric van der Essen
2015-02-02 16:29:32 +01:00
parent 3335a79e6b
commit 82ae362aba
3 changed files with 99 additions and 2 deletions
@@ -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()) {
@@ -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 ------- */
@@ -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){