[FIX] pos_coupon: Coupons code disappear when switching table
Current behavior: When adding a coupon with a code in a PoS (restaurant/bar) if you switch table and come back to the first table the coupon code is disappearing Steps to reproduce: - Activate promo code for a PoS (restaurant/bar) - Go on table A, add some product and enter a code for the order - Leave table, and come back to table A - The promo code has dissapeared note: A better fix could be done on master adding bookedCouponCode on order field to save it between the table switching. opw-2733081 closes odoo/odoo#85524 X-original-commit: bdc4895226374932a92a543ff25ea1a41d5a4ce8 Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -64,7 +64,11 @@ class PosOrder(models.Model):
|
||||
|
||||
def _get_fields_for_order_line(self):
|
||||
fields = super(PosOrder, self)._get_fields_for_order_line()
|
||||
fields.append('is_program_reward')
|
||||
fields.extend({
|
||||
'is_program_reward',
|
||||
'coupon_id',
|
||||
'program_id',
|
||||
})
|
||||
return fields
|
||||
|
||||
class PosOrderLine(models.Model):
|
||||
|
||||
@@ -238,9 +238,9 @@ odoo.define('pos_coupon.pos', function (require) {
|
||||
this._initializePrograms();
|
||||
}
|
||||
init_from_JSON(json) {
|
||||
this.bookedCouponCodes = this.bookedCouponCodes ? this.order.bookedCouponCodes : {};
|
||||
this.activePromoProgramIds = this.activePromoProgramIds ? this.order.activePromoProgramIds : [];
|
||||
super.init_from_JSON(...arguments);
|
||||
this.bookedCouponCodes = json.bookedCouponCodes;
|
||||
this.activePromoProgramIds = json.activePromoProgramIds;
|
||||
}
|
||||
export_as_JSON() {
|
||||
let json = super.export_as_JSON(...arguments);
|
||||
@@ -1022,6 +1022,11 @@ odoo.define('pos_coupon.pos', function (require) {
|
||||
this.is_program_reward = json.is_program_reward;
|
||||
this.program_id = json.program_id;
|
||||
this.coupon_id = json.coupon_id;
|
||||
if (this.coupon_id && this.coupon_id[1]) {
|
||||
this.order.bookedCouponCodes[this.coupon_id[1]] = new CouponCode(this.coupon_id[1], this.coupon_id[0], this.program_id[0]);
|
||||
} else if (json.program_id && json.program_id[0]) {
|
||||
this.order.activePromoProgramIds.push(json.program_id[0]);
|
||||
}
|
||||
}
|
||||
super.init_from_JSON(...arguments);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user