Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
Created May 23, 2020 05:42
Show Gist options
  • Select an option

  • Save sehrishnaz/861bdbba660525fd3ec62c0d1b4b6d18 to your computer and use it in GitHub Desktop.

Select an option

Save sehrishnaz/861bdbba660525fd3ec62c0d1b4b6d18 to your computer and use it in GitHub Desktop.
Show one2many field records as radio button in odoo wizard, Convert one2many field into selection field | Odoo, Use radio widget in one2many field | Odoo, Set default value of selection field using context | Odoo, Fill selection field using context | Odoo, Mapping one2many field into selection field | Odoo
class wizard_model_name(models.TransientModel):
_name = 'wizard.model.name'
@api.multi
def _get_one2many_records(self):
lst = []
if self.env.context.get('option_data') != None:
one2many_record_obj = self.env['one2many.model.name'].search([('id','in',self.env.context.get('your_context_variable'))])
for data in one2many_record_obj:
lst.append((data.key, data.value))
return lst
selection_field_name = fields.Selection(_get_one2many_records, string="Selection")
@api.multi
def button_event(self):
view_id_form = self.env['ir.ui.view'].search([('name','=',"wizard.model.form.name")])
ctx = {
'your_context_variable':one2many_field.ids
}
return {
'type': 'ir.actions.act_window',
'res_model': 'wizard.model.name',
'view_type': 'form',
'view_mode': 'form',
'target': 'inline',
'view_id': view_id_form.id,
'auto_refresh':1,
'context':ctx
}
@sehrishnaz
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment