summaryrefslogtreecommitdiff
path: root/addons/pos_restaurant/static/src/js/multiprint.js
diff options
context:
space:
mode:
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>2014-11-03 18:27:51 +0100
committerFrédéric van der Essen <fvdessen@gmail.com>2014-11-26 11:40:17 +0100
commit44253541e5da4903e4aa20c767c5f275e8ce7ee6 (patch)
treeb430909f699ee7faafd873f4757742bce4dd4244 /addons/pos_restaurant/static/src/js/multiprint.js
parentbdca47e381002a5d049ad29d7faf6fac39930116 (diff)
[IMP] point_of_sale, pos_*: unpaid orders are saved in localstorage and persist between reloads
Conflicts: addons/point_of_sale/static/src/js/models.js addons/point_of_sale/static/src/js/screens.js addons/pos_restaurant/static/src/js/multiprint.js addons/pos_restaurant/static/src/js/notes.js Conflicts: addons/point_of_sale/static/src/js/models.js addons/point_of_sale/static/src/js/screens.js addons/point_of_sale/static/src/xml/pos.xml
Diffstat (limited to 'addons/pos_restaurant/static/src/js/multiprint.js')
-rw-r--r--addons/pos_restaurant/static/src/js/multiprint.js46
1 files changed, 36 insertions, 10 deletions
diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js
index 90302870133..8b1f9e94654 100644
--- a/addons/pos_restaurant/static/src/js/multiprint.js
+++ b/addons/pos_restaurant/static/src/js/multiprint.js
@@ -54,26 +54,43 @@ function openerp_restaurant_multiprint(instance,module){
},
});
+ module.Orderline = module.Orderline.extend({
+ get_line_diff_hash: function(){
+ if (this.get_note()) {
+ return this.get_product().id + '|' + this.get_note();
+ } else {
+ return '' + this.get_product().id;
+ }
+ },
+ });
+
+ var _super_order = module.Order.prototype;
module.Order = module.Order.extend({
lineResume: function(){
var resume = {};
- this.get('orderLines').each(function(item){
- var line = item.export_as_JSON();
- if( typeof resume[line.product_id] === 'undefined'){
- resume[line.product_id] = line.qty;
- }else{
- resume[line.product_id] += line.qty;
+
+ this.orderlines.each(function(line){
+ var line_hash = line.get_line_diff_hash();
+ var qty = Number(line.get_quantity());
+ var note = line.get_note();
+ var product_id = line.get_product().id;
+
+ if (typeof resume[line_hash] === 'undefined') {
+ resume[line_hash] = { qty: qty, note: note, product_id: product_id };
+ } else {
+ resume[line_hash].qty += qty;
}
});
return resume;
},
saveChanges: function(){
- this.old_resume = this.lineResume();
+ this.saved_resume = this.build_line_resume();
+ this.trigger('change',this);
},
computeChanges: function(categories){
- var current = this.lineResume();
- var old = this.old_resume || {};
- var json = this.export_as_JSON();
+ var current_res = this.build_line_resume();
+ var old_res = this.saved_resume || {};
+ var json = this.export_as_JSON();
var add = [];
var rem = [];
@@ -174,6 +191,15 @@ function openerp_restaurant_multiprint(instance,module){
}
return false;
},
+ export_as_JSON: function(){
+ var json = _super_order.export_as_JSON.apply(this,arguments);
+ json.multiprint_resume = this.saved_resume;
+ return json;
+ },
+ init_from_JSON: function(json){
+ _super_order.init_from_JSON.apply(this,arguments);
+ this.saved_resume = json.multiprint_resume;
+ },
});
module.PosWidget.include({