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

I know I can specify the default value for a field in a one2many widget with tree view customizing the create control like this

<control>   
   <create string="Add a red one"
    context="{'default_color': 'red'}"
  />
  <create string="Add a blue one"
    context="{'default_color': 'blue'}"
  />
</control>
Can I do the same using a value from a field in the "header", I tried this one but doesn't work

<control>   
   <create string="Add one with color from an header field"     
   context="{'default_color': color_field}" 
  />
</control>

Avatar
Discard
Best Answer

No, you could not.
Create control just pass the static string as context. I would not eval any expression
ref: https://github.com/odoo/odoo/blob/12.0/addons/web/static/src/js/views/list/list_editable_renderer.js#L69

Avatar
Discard