From e13088b62ef5756014bdf85e98d38fae1821ae4c Mon Sep 17 00:00:00 2001 From: Horacio Tellez Date: Thu, 29 Sep 2022 13:58:01 +0000 Subject: [PATCH] [FIX] loyalty: amount conversion of rules without company In the present when in a multi-company environment it is possible to create loyalty programs without a company associated to it. This cause a problem when computing conversion rates as conversion rates are associated to a company. After this commit if no company is setted on the loyalty program then when computing the amout to deduce on the loyalty program we fallback to the env company (this is the same way the company is initially deduced on the loyalty program). Task - 3001177 closes odoo/odoo#101922 Forward-port-of: odoo/odoo#101631 Signed-off-by: Victor Feyens (vfe) --- addons/loyalty/models/loyalty_rule.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/loyalty/models/loyalty_rule.py b/addons/loyalty/models/loyalty_rule.py index 24210efadbb..ebf0066843a 100644 --- a/addons/loyalty/models/loyalty_rule.py +++ b/addons/loyalty/models/loyalty_rule.py @@ -134,4 +134,8 @@ class LoyaltyRule(models.Model): def _compute_amount(self, currency_to): self.ensure_one() return self.currency_id._convert( - self.minimum_amount, currency_to, self.company_id, fields.Date.today()) + self.minimum_amount, + currency_to, + self.company_id or self.env.company, + fields.Date.today() + )