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.
<?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.
Upgrading to Odoo 10 right now. I didn't figure out how to change my Server Actions like
ReplyDeleteself.write(cr, uid, context['active_ids'], {'to_wait':'No'})
any clue for me?
Thanks.
I reply myself:
ReplyDeletepos_obj = env['pos.order'].browse(context.get('active_ids'))
pos_obj.write({'to_wait': 'No'})
But how to call a method like
ReplyDelete@api.Multi
def my_stuff(self):
my_code_here