Here is my code :
<!-- ================================ -->
<!-- Create a matching from a product -->
<!-- ================================ -->
<record model="ir.values" id="product.product_link_to_label">
<field name="name">Create Matching</field>
<field name="key2">client_action_multi</field>
<field name="type">object</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_create_matching_tree'))" />
<field name="key">action</field>
<field name="model">product.product</field>
</record>
<record model="ir.ui.view" id="label.tree_new_match">
<field name="name">Create Matching</field>
<field name="model">label.label</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="arch" type="xml">
<tree colors="green:len(products)==0;red:len(products)!=0" default_order='len_products, real_id' create='false' delete='false'>
<button string="New" type="object" name="new_match"/> <==== THIS Button where i got trouble to pass values trough context
<field name="nom" string="Name"/>
<field name="real_id"/>
<field name="type"/>
<field name="products"/>
<field name="len_products" invisible="context.get('len_products')!=1000"/>
</tree>
</field>
</record>
<record id="action_create_matching_tree" model="ir.actions.act_window">
<field name="name">Create Matching</field>
<field name="res_model">label.label</field>
<field eval="0" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="label.tree_new_match" />
</record>
Python fun in my label model:
def new_match(self):
self = self.with_context(products=self._context.get('active_ids'))
return {
'name':_("Save a new matching"),
'view_mode': 'form',
'view_type': 'form',
'view_id': False,
'res_model': 'label.label',
'res_id': self.id,
'type': 'ir.actions.act_window',
'target': 'current',
'domain': '[]',
'flags': {'initial_mode': 'edit'},
}
I would like the record not to be saved this way, but just replace fields like if the user added them manually and was about to save it.