account_credit_hold: take parent company hold status into consideration

This commit is contained in:
Marc Durepos 2024-05-29 13:28:48 -04:00
parent 9c0ddb4812
commit 6f8e19156a
2 changed files with 6 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{
'name': 'Account Credit Hold',
'version': '17.0.1.0.0',
'version': '17.0.1.1.0',
'summary': 'Allows setting clients on credit hold, blocking the ability confirm a new sales order.',
'description': 'Allows setting clients on hold, blocking the ability confirm a new sales order.',
'category': 'Accounting/Accounting',

View file

@ -26,6 +26,11 @@ class Partner(models.Model):
# by an SQL query every time
self._compute_hold_bg()
for rec in self:
# If the parent company is on hold, so are all its sub-contacts and subsidiaries
if rec.commercial_partner_id and rec.commercial_partner_id.on_hold:
rec.on_hold = True
return
# If there is no parent company or the parent is not on hold, we compute for ourselves
if rec.hold_bg and not (rec.postpone_hold_until and rec.postpone_hold_until > date.today()):
rec.on_hold = True
else: