跳至内容
菜单
此问题已终结
1 回复
3542 查看

I write a "def confirm_sale(self, cr, uid, ids, context=None):…………" in saly.py/class sale.order, and i write the "ir.actions.server" like:

<record id="action_sale_order_action_cancel" model="ir.actions.server">
<field name="name">Cancel1</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.confirm_sale(context=context)</field>**
</record>
<record id="id_action_sale_order_action_cancel" model="ir.values">
<field name="name">Cancel</field>
<field name="action_id" ref="action_sale_order_action_cancel"/>
<field name="value" eval="'ir.actions.server,' + str(ref('action_sale_order_action_cancel'))"/>
<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>

but it always take the error:
" openerp.tools.safe_eval: Cannot eval u'obj.confirm_sale(context=context)' "

" AttributeError: "Field 'confirm_sale' does not exist in object 'browse_record(sale.order, 10)'" "

But if I replace confirm_sale with action_button_confirm , which has already exist in saly.py, it can work ..

I think I should add something more..But I don't know how to collect...

形象
丢弃
最佳答案

If I understand you correctly, when using the method action_button_confirm it is working, while using the method confirm_sale you get an error? If that is true, did you restart the openERP server, so that it knows the changed code, and have you reloaded (or loaded for the first time) your module?

形象
丢弃
编写者

yeah .....when I restart it ...it can work......................................thanks :D