Calling a python method (server action) directly from menuitem or button


Here is an example:

Server Action

<record id="action_make_testing" model="ir.actions.server">

<field name="name">Make Testing</field>

<field name="condition">True</field>

<field name="type">ir.actions.server</field>

<field name="model_id" ref="model_res_partner" />

<field name="state">code</field>

<field name="code">self.test_act(cr, uid, context.get('active_ids', []), context=context)</field>

</record>

Menu:

<menuitem id='menu_testing' name='Testing' sequence="100" parent="base.menu_base_config" action="action_make_testing"/>

Python code to run : Method name = test_act

class res_partner(osv.osv):

     _inherit = 'res.partner'

     def test_act(self,cr,uid,ids,context={}):

         return True 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s