This question has been flagged
1 Reply
9874 Views

Hello I'm trying to develop a ir.actions.server in a custom tree view. When I select some checkbox (the typical checkbox that it appears at first position in a tree) and I click in the button that I created, it always executes my code in the first item, not in all rows that I selected... How I can tell to OpenERP that it has to do it in all rows I selected?

This is my xml <record id="action_sale_order_liquidar" model="ir.actions.server"> <field name="name">Liquidar</field> <field name="type">ir.actions.server</field> <field name="model_id" ref="model_sale_order"/> <field name="state">code</field> <field name="code">obj.button_add_field(context=context)</field>

    </record>
    <record id="id_of_the_action_value" model="ir.values">
        <field name="name">Liquidar</field>
        <field name="action_id" ref="action_sale_order_liquidar"/>
        <field name="value" eval="'ir.actions.server,' + str(ref('action_sale_order_liquidar'))"/>
        <field name="key">action</field>
        <field name="model_id" ref="model_sale_order"/>
        <field name="model">sale.order</field>
        <field name="key2">client_action_multi</field>

    </record>

and this my py; def button_add_field(self, cursor, uid, ids, context): for i in ids:
cursor.execute("UPDATE sale_order SET estado1='complete' WHERE id = "+str(i)) return True

Thanks in advance

Avatar
Discard
Author Best Answer

I found the problem, I have to change this line: <field name="code">obj.button_add_field(context=context)</field> to <field name="code">self.function_to_run(cr, uid, context.get('active_ids'), context=context)</field>

where function_to_run is the function which openerp will call

Avatar
Discard

Hi victor, can I ask if this is for the confirmation of more than one sales order at a time?

Were you able to open the sale order form after the function was ran? I am having this problem now where the form doesn't open after the function is ran