Skip to Content
Menu
This question has been flagged
1 Reply
807 Views

I have created custom selection filed in res.partner module name ven_cat which have differnat seletion like trade, non-trade, capex etc.

I want to use onchange function of the selection filed ven_cat so after selection of trade in ven_cat filed another selection field need to change automatically. the other filed need to change is also a selection field name account payable which have different ledgers available (I want to select one ledger out of it how we can achieve that ?)

@api.onchange("ven_cat")
def onchange_ven_cat(self):
if self.ven_cat == "trade":



Avatar
Discard
Best Answer

Hi,

Account payable field (property_account_payable_id) is a many2One field. Which is relation to account.account model. So you need to make a connection to which account to opt for when select ven_cat field to trade or other selection data.

You may can use the account code. So if you wish to use Account Recievable (code='11000')

@api.onchange("ven_cat")
def onchange_ven_cat(self):
if self.ven_cat == "trade":
        self.property_account_payable_id = self.env['account.account'].search([('code', '=', '11000')]).id

Regards

Avatar
Discard