From 496ee650da72796443f080cddf7be0eeadf67658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 11 Oct 2024 19:31:14 +0200 Subject: [PATCH] Do not use negative company ID from context to compute credit limit Closes #13596 --- modules/account_credit_limit/party.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/account_credit_limit/party.py b/modules/account_credit_limit/party.py index 3697ae4dc7..5525c86737 100644 --- a/modules/account_credit_limit/party.py +++ b/modules/account_credit_limit/party.py @@ -61,6 +61,10 @@ class Party(metaclass=PoolMeta): if self.credit_limit_amount is None: return + company_id = Transaction().context.get('company') + if company_id is None or company_id < 0: + return + company = Company(company_id) def in_group(): group = Group(ModelData.get_id('account_credit_limit', @@ -78,7 +82,6 @@ class Party(metaclass=PoolMeta): Model = pool.get(model) Model.lock() if self.credit_limit_amount < self.credit_amount + amount: - company = Company(Transaction().context.get('company')) lang = Lang.get() limit = lang.currency(self.credit_limit_amount, company.currency) if not in_group(): @@ -121,7 +124,7 @@ class Party(metaclass=PoolMeta): pool = Pool() Company = pool.get('company.company') company_id = Transaction().context.get('company') - if company_id: + if company_id is not None and company_id >= 0: company = Company(company_id) return company.currency.digits