4
votes

I'm trying to make a shortcut to get from a production order to the packing list for its raw materials in OpenERP.

I can get the related window link to appear on the production order form, but I'd really like to be able to get to the packing list from the production order tree view by clicking on the Action button at the top of the screen. That way, I wouldn't have to open the production order form. It seems like a wizard can be accessed from the tree view by using the keyword="client_action_multi" attribute in the <wizard> tag. Is there something equivalent for a window action?

I guess I could write a wizard that triggers a window action, but I was hoping for something simpler.

2

2 Answers

6
votes

Thanks to QGerome's help, I got this working. I found an example to follow in the hr module:

    <record id="action2" model="ir.actions.act_window">
        <field name="name">Employee Hierarchy</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">hr.employee</field>
        <field name="domain">[('id','in',active_ids)]</field>
        <field name="view_type">tree</field>
        <field name="view_id" ref="view_partner_tree2"/>
    </record>
    <ir_set>
        <field eval="'action'" name="key"/>
        <field eval="'client_action_multi'" name="key2"/>
        <field eval="['hr.employee']" name="models"/>
        <field name="name">Employees Hierarchy</field>
        <field eval="'ir.actions.act_window,'+str(action2)" name="value"/>
        <field eval="True" name="isobject"/>
        <field eval="True" name="replace"/>
    </ir_set>

I'm not sure exactly what the difference is between the <ir_set> tag and a raw ir.values record, but the data import code in convert.py seemed to be calling ir_set(), so I went with that.

You can see my complete solution on launchpad.

1
votes

You can create a ir.values record

<record model="ir.values" id="the_id">
        <field name="name">The label</field>
        <field name="model" eval="'src_model'"/>
        <field name="key" >action</field>
        <field name="key2">client_action_multi</field>
        <field name="value" eval="'ir.actions.act_window,%d'%action_id"/>
        <field name="object" eval="True"/>
    </record>

or from the menu : Administration / Low Level Objects / Client Actions Connections