Im using two models for two form views. I have this field below with model 1
name = fields.Many2one('hr.employee', string="USERNAME", required=True)
And I want to pass its value to the wizard when I click a button. Here's the code:
def create_field(self):
return { 'name': self.name, 'view_mode': 'form', 'res_model': 'dieu.chinh', 'view_id': False, 'res_id': wiz.id, 'res_id' : self.id, 'context': {'current_id': self.id}, 'target': 'current', 'type': 'ir.actions.act_window', }
The button in XML file:
button type="object" string="SUBMIT" name= "create_field" class="oe_highlight"/>
After clicking the button, it can open the expected form view with model 2, but still not show the value which was selected in the previous form.
So... How to pass value from field to a wizard in Odoo 13?
Please help!
Thank you!
create_field
.'context': {'current_id': self.id, 'default_name': self.name},
– Kenlyname
field is aMany2one
field so try to pass itsid
like following:'context': {'current_id': self.id, 'default_name': self.name.id},
– Kenly