Saturday, 12 November 2016

How to create server actions in Odoo 10?

Below is example of server actions in Odoo 8.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <data>
        <record id="action" model="ir.actions.server">
            <field name="name">My Action</field>
            <field name="model_id" ref="model_module_model"/>
            <field name="code">self.action(cr, uid, context=context)</field>
       </record>
    </data>
</odoo>

Following is example for Server actions in Odoo 10.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>

    <data>
        <record id="action" model="ir.actions.server">
            <field name="name">My Action</field>
            <field name="model_id" ref="model_module_model"/>
            <field name="code">
           
            if context.get('active_model') == 'your.module.model' and context.get('active_ids'):
                    action = env['module.model'].browse(context['active_ids']).action()
          
            </field>
       </record>
    </data>
</odoo>


There is no need of self variable to declare server action in Odoo 10.

3 comments:

  1. Upgrading to Odoo 10 right now. I didn't figure out how to change my Server Actions like

    self.write(cr, uid, context['active_ids'], {'to_wait':'No'})

    any clue for me?
    Thanks.

    ReplyDelete
  2. I reply myself:

    pos_obj = env['pos.order'].browse(context.get('active_ids'))
    pos_obj.write({'to_wait': 'No'})

    ReplyDelete
  3. But how to call a method like

    @api.Multi
    def my_stuff(self):
    my_code_here

    ReplyDelete

Error: Hash Sum mismatch in GitLab

Recently, I have faced following error during instillation of Gitlab in Ubuntu. odedra@odedra-Lenovo-Z50-70:~$ sudo apt-get install gitla...