From ec0fc574622579c6b031f28b7878c288e55b8628 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 15 Feb 2021 17:41:45 +0000 Subject: [PATCH] [FIX] sale_coupon: prevent program w/o company The company is used to compute currency of: - discount_fixed_amount - discount_max_amount - rule_minimum_amount If currently we don't set a company, we have an error when using the company. opw-2458950 note: forward-port in master set the company field as required setting it as required in the view. closes odoo/odoo#66231 X-original-commit: d260dddcdeddecd2bc0649d948f5e0cc30607e09 Signed-off-by: Nicolas Lempereur (nle) --- addons/coupon/models/coupon_program.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/coupon/models/coupon_program.py b/addons/coupon/models/coupon_program.py index 04657feb3d3..60c6f76d958 100644 --- a/addons/coupon/models/coupon_program.py +++ b/addons/coupon/models/coupon_program.py @@ -47,7 +47,7 @@ class CouponProgram(models.Model): default='on_current_order', string="Applicability") coupon_ids = fields.One2many('coupon.coupon', 'program_id', string="Generated Coupons", copy=False) coupon_count = fields.Integer(compute='_compute_coupon_count') - company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.company) + company_id = fields.Many2one('res.company', string="Company", required=True, default=lambda self: self.env.company) currency_id = fields.Many2one(string="Currency", related='company_id.currency_id', readonly=True) validity_duration = fields.Integer(default=30, help="Validity duration for a coupon after its generation")