Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Can I write a function and make it work?

By
CK
on 3/26/13, 11:59 PM 983 views

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...

1

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 3/27/13, 5:12 AM

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

CK
on 3/27/13, 5:44 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/26/13, 11:59 PM
Seen: 983 times
Last updated: 3/16/15, 8:10 AM