From 6f8e19156aa9fa0879d8bab36b49ec6a480ed0d3 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Wed, 29 May 2024 13:28:48 -0400 Subject: [PATCH] account_credit_hold: take parent company hold status into consideration --- account_credit_hold/__manifest__.py | 2 +- account_credit_hold/models/res_partner.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/account_credit_hold/__manifest__.py b/account_credit_hold/__manifest__.py index b5cc33a..e45d9e4 100644 --- a/account_credit_hold/__manifest__.py +++ b/account_credit_hold/__manifest__.py @@ -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', diff --git a/account_credit_hold/models/res_partner.py b/account_credit_hold/models/res_partner.py index 76a601c..37ac13b 100644 --- a/account_credit_hold/models/res_partner.py +++ b/account_credit_hold/models/res_partner.py @@ -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: