This question has been flagged

In Odoo v9 I append a button to a tree, like this

<field name="order_line_group" nolabel="1">
<tree string="Productos" editable="bottom" create="false">
<field name="sequence" widget="handle"/>
<field name="product_id"/>
<field name="name"/>
<field name="price_unit"/>
<field name="product_uom_qty"/>
<field name="price_subtotal"/>
<field name="price_total"/>
<button name="%(module.action_name)d"
type="action"
icon="fa-th"
class="oe_edit_only"
context="{'default_product_tmpl_id': product_id}"
/>
</tree>
</field>

But when I click on the button, the default_product_tmpl_id it pass when the first line "product_id".... .

How do I pass the value of the line of the button clicked..

Avatar
Discard
Best Answer

Hello Mariano DAngelo,

For default context pass in wizard, you can called default_get method for that.

For Ex:-
You can write method in wizard model.

@api.model
def default_get(self, fields):
    rec = super(WizardModel, self).default_get(fields)
    active_model_id = self.env['order.line.model'].browse(self._context.get('active_id'))
    rec['wizard_field'] = active_model_id.active_model_field
    return rec

When you called wizard on line, value of your line product_id automatically field in wizard field.

Hope it will works for you.
Thanks,

Avatar
Discard