Reputation: 27
Good day, I want to get the bank details a client via a smart button in odoo 14. The code below gives me an error when i run it.
def action_bank_details_preview(self):
action = self.env["ir.actions.actions"]._for_xml_id("base.res_partner_bank")
action['domain'] = [('partner_id','=',self.partner_id.id)]
action['context'] = {'default_partner_id': self.partner_id.id}
return action
Upvotes: 0
Views: 403
Reputation: 14768
The xml or external ID for the default bank accounts menu action is base.action_res_partner_bank_account_form
And try to use the correct model: ir.actions.act_window
.
Or another way is to use self.env.ref(<xml_id>).read()[0]
def action_bank_details_preview(self):
action_xml_id = 'base.action_res_partner_bank_account_form'
action = self.env.ref(action_xml_id).read()[0]
action['domain'] = [('partner_id','=',self.partner_id.id)]
action['context'] = {'default_partner_id': self.partner_id.id}
return action
Upvotes: 1