From f753c5dce173bad31e614b164d3b0aa12c497fa1 Mon Sep 17 00:00:00 2001 From: Bhavesh Heliconia Date: Mon, 18 May 2026 16:18:57 +0530 Subject: [PATCH] [FIX] account_brand: Replace deprecated onchange domain return with a dynamic expression on field definition --- .../models/res_partner_account_brand.py | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/account_brand/models/res_partner_account_brand.py b/account_brand/models/res_partner_account_brand.py index c4c793f1a..a5e5159e4 100644 --- a/account_brand/models/res_partner_account_brand.py +++ b/account_brand/models/res_partner_account_brand.py @@ -19,7 +19,10 @@ class ResPartnerAccountBrand(models.Model): comodel_name="account.account", string="Account", required=True, - domain="[('account_type', 'in', ('liability_payable', 'asset_receivable'))]", + domain=( + "[('account_type', '=', account_type), ('deprecated', '=', False)] " + "if account_type else [('id', '=', False)]" + ), ) brand_id = fields.Many2one(comodel_name="res.brand", string="Brand", required=True) account_type = fields.Selection( @@ -53,20 +56,7 @@ def _check_account_type(self): @api.onchange("account_type") def _onchange_account_type(self): - self.ensure_one() - self.update({"account_id": False}) - domain = [("id", "=", False)] - if self.account_type == "payable": - domain = [ - ("internal_type", "=", "payable"), - ("deprecated", "=", False), - ] - elif self.account_type == "receivable": - domain = [ - ("internal_type", "=", "receivable"), - ("deprecated", "=", False), - ] - return {"domain": {"account_id": domain}} + self.account_id = False @api.model def _get_partner_account_by_brand(self, account_type, brand, partner):