Reputation: 39
I am trying to create a button on product form. here is my xml
<record id="action_button" model="ir.actions.server">
<field name="type">ir.actions.server</field>
<field name="condition">True</field>
<field name="state">code</field>
<field name="model_id" ref="product_normal_form_view"/>
<field eval="5" name="sequence"/>
<field name="code">action=self.action_button(cr,uid, context)</field>
</record>
=================
<group col="2" colspan="2">
<button name="%(action_button)d" type="action" string="Test Hello"/>
</group>
def action_button(cr,uid,context):
test={}
modelname="Hello Usha"
test['tryhello']=modelname
return{'value':test}
=============
pl. help, thanks in advance
-Usha
Upvotes: 1
Views: 3253
Reputation: 3743
I have tried your code and after modification it's working fine and the method is also executing.
<record id="action_button" model="ir.actions.server">
<field name="type">ir.actions.server</field>
<field name="name">Testing</field>
<field name="condition">True</field>
<field name="state">code</field>
<field name="model_id" ref="model_product_product"/>
<field eval="5" name="sequence"/>
<field name="code">action=obj.action_button(context=context)</field>
</record>
def action_button(self, cr, uid, ids, context=None):
#your code
Hope this will solve your problem.
Upvotes: 1
Reputation:
Try below code::
<record id="action_button" model="ir.actions.server">
<field name="type">ir.actions.server</field>
<field name="condition">True</field>
<field name="state">code</field>
<field name="model_id" ref="product_normal_form_view"/>
<field eval="5" name="sequence"/>
<field name="code">action=self.pool.get('product.product').action_button(cr, uid, context
</field>
and make change also in py file where we the action_button method define
def action_button(self, cr, uid, context=None):
test={}
modelname="Hello usha"
test['tryhello']=modelname
return{'value':test}
Upvotes: 1