Do not use negative company ID from context to compute credit limit

Closes #13596
This commit is contained in:
Cédric Krier
2024-10-11 19:31:14 +02:00
parent d967356c7e
commit 496ee650da
+5 -2
View File
@@ -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