This question has been flagged
1 Reply
5952 Views

A tree view of many2many field has buttons in its rows:

<field name="my_tasks">
    <tree>
        <button name="%(task_form_action)d" string="смотреть" type="action"/>
        ...
    </tree>
</field>

Button calls for an action:

<record model="ir.actions.act_window" id="task_form_action">
        <field name="name">Task.form.action</field>
        <field name="res_model">myproject.task</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="target">current</field>
        <field name="view_id" ref="tasks_form_view"/>
        <field name="res_id">???</field>

What have I put into action's "res_id" field to open the existing record's form window? 
(Not for creating a new one!!)
When I put an integer, the window for record with such an id opens. 
But how can I eval active_id from row which the button is located in?

Avatar
Discard
Best Answer

Try these code, I didn't test and not sure it will work.  

<field name="my_tasks">
    <tree>
        <button name="%(task_form_action)d" string="смотреть" type="action" context="{'active_id': id}"/>
        ...
    </tree>
</field>



<record model="ir.actions.act_window" id="task_form_action">
        <field name="name">Task.form.action</field>
        <field name="res_model">myproject.task</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="target">current</field>
        <field name="view_id" ref="tasks_form_view"/>
        <field name="res_id">context.get('active_id', False)</field>


Avatar
Discard