summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>2014-11-04 17:23:26 +0100
committerFrédéric van der Essen <fvdessen@gmail.com>2014-11-26 11:40:22 +0100
commit574a17d8a2a126e34f7a3769e596d8bcc2cab112 (patch)
treeec0fe06721d9e6421507930c7dfd3fb0133e9c01
parentba380c807ed695cb96ea2aaffbd396910eff4732 (diff)
[FIX] point_of_sale: paymentlines were not properly saved and restored
Conflicts: addons/point_of_sale/static/src/js/models.js
-rw-r--r--addons/point_of_sale/static/src/js/models.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index b04ab9392cc..3b3505b1d17 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -987,12 +987,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
init_from_JSON: function(json){
this.amount = json.amount;
this.cashregister = this.pos.cashregisters_by_id[json.statement_id];
- this.name = this.cashregister.journal_id[0];
+ this.name = this.cashregister.journal_id[1];
},
//sets the amount of money on this payment line
set_amount: function(value){
this.amount = round_di(parseFloat(value) || 0, this.pos.currency.decimals);
- this.trigger('change:amount',this);
+ this.trigger('change',this);
},
// returns the amount of money on this paymentline
get_amount: function(){
@@ -1004,7 +1004,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
set_selected: function(selected){
if(this.selected !== selected){
this.selected = selected;
- this.trigger('change:selected',this);
+ this.trigger('change',this);
}
},
// returns the associated cashregister
@@ -1062,9 +1062,13 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
this.name = _t("Order ") + this.uid;
}
- this.on('change', this.save_to_db, this);
- this.orderlines.on('change', this.save_to_db, this);
- this.paymentlines.on('change', this.save_to_db, this);
+ this.on('change', function(){ this.save_to_db("order:change"); }, this);
+ this.orderlines.on('change', function(){ this.save_to_db("orderline:change"); }, this);
+ this.orderlines.on('add', function(){ this.save_to_db("orderline:add"); }, this);
+ this.orderlines.on('remove', function(){ this.save_to_db("orderline:remove"); }, this);
+ this.paymentlines.on('change', function(){ this.save_to_db("paymentline:change"); }, this);
+ this.paymentlines.on('add', function(){ this.save_to_db("paymentline:add"); }, this);
+ this.paymentlines.on('remove', function(){ this.save_to_db("paymentline:rem"); }, this);
this.init_locked = false;
this.save_to_db();
@@ -1104,7 +1108,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
var paymentlines = json.statement_ids;
for (var i = 0; i < paymentlines.length; i++) {
var paymentline = paymentlines[i][2];
- this.paymentlines.add(new module.Paymentline({},{pos: this.pos, json: paymentline}));
+ var newpaymentline = new module.Paymentline({},{pos: this.pos, json: paymentline});
+ this.paymentlines.add(newpaymentline);
+
+ if (i === paymentlines.length - 1) {
+ this.select_paymentline(newpaymentline);
+ }
}
},
export_as_JSON: function() {