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

Is the 'Write' function always called when I click a button ? (V7)

By
Pierre Beghin
on 3/6/15, 4:45 AM 442 views

If I add a button of type 'object' on a form in order to call a custom python procedure, the write function is always called before my procedure is called.

I need a way to bypass the write and just call my procedure.

I tried to put some info in the context declaration of the button, but the context is not passed to the write function, only to my procedure.

Is there something I am missing?

Thanks

 

2

Vasanth

--Vasanth--
3458
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
On 3/6/15, 8:26 AM

hi,

When you click the button , first it triggers the write method and save the record and then proceed other things.

you can get your answer in the following links:

http://stackoverflow.com/questions/21575405/what-is-write-function-in-openerp-framework

http://stackoverflow.com/questions/14197116/which-function-is-invoked-when-the-save-button-is-clicked-in-openerp6-1

0
Pierre Beghin
On 3/6/15, 8:55 AM

Thank you Vasanth.

So it seem that triggering the write method cannot be avoided, isnt'it ?

Do you know a way to provide some context to the write method ?

As I tried, giving a context to the button will only forward it to the referred method, not to the write one.

ex: <button string="Do something" name="do_something" type="object" context="{'some_info':'any'}"/>

will indeed call the python do_something() method with the required 'some_info' in the context.

Unfortunately, the write method that is triggered before doesn't receive the 'some_info' parameter in its context !

In a word, I try to trigger a method that does some computation with the values in the form, before they get saved.

An idea ?

 

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/6/15, 4:45 AM
Seen: 442 times
Last updated: 3/16/15, 8:10 AM