1
votes

I have written a onchange method on the many2one field using new api for v9. my code is

branch_id = fields.Many2one('branch.branch', 'Branch')

@api.onchange('branch_id')
def onchange_branch(self):
    if self.branch_id:
        self.shop_ids = self.branch_id.shop_ids

I have not added the on change on the xml also. when i do the change the many2one field the on change method is not getting called.

Also On developer mode tooltip i can not see the onchange while on other filed i can see.

Does anyone have idea what I am missing?

1
Could you show us some more code? The class, the branch_id definition. Are the files correctly initialized?CZoellner
@CZoellner Here it is!Alpha Geek
Thx, but it's not helping. Did you restart the server and update your custom module? Then reload the client (F5). And another thing: Shouldn't the shop_ids set to nothing, when the branch_id is emptied?CZoellner

1 Answers

1
votes

I faced this kind of issue while migrating code from v7 to v9. where I was changing the methods from old api to odoo new api. that time i forgot to comment the old api method.

May be this can be your issue.

kindly check your for the method onchange_branch, if you have two method with same name or not. if yes then remove the extra method.