From f36ad3523b4a31544e3b7cb5d2be8f36fc54a7af Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Fri, 7 Jul 2023 08:41:00 +0000 Subject: [PATCH] [IMP] account_reports: reset country_id when switching the availability condition of a report manually to something else than 'country' Otherwise, when displaying the field in the view, the field might remain set, causing confusion. closes odoo/odoo#128143 X-original-commit: 003edebd7e90d3e24a2f932c5ff90b1b13758b35 Signed-off-by: John Laterre (jol) --- addons/account/models/account_report.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_report.py b/addons/account/models/account_report.py index a0ae244fb32..98ce6c04b71 100644 --- a/addons/account/models/account_report.py +++ b/addons/account/models/account_report.py @@ -129,7 +129,7 @@ class AccountReport(models.Model): else: report[field_name] = default_value - @api.depends('root_report_id', 'country_id') + @api.depends('root_report_id') def _compute_default_availability_condition(self): for report in self: if report.root_report_id: @@ -143,6 +143,11 @@ class AccountReport(models.Model): if report.root_report_id.root_report_id: raise ValidationError(_("Only a report without a root report of its own can be selected as root report.")) + @api.onchange('availability_condition') + def _onchange_availability_condition(self): + if self.availability_condition != 'country': + self.country_id = None + def write(self, vals): # Overridden so that changing the country of a report also creates new tax tags if necessary, or updates the country # of existing tags, if they aren't shared with another report.