Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions account_brand/models/res_partner_account_brand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
Loading