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

Preventing On change recursion

By
leo
on 12/6/13, 4:24 PM 1,141 views

hello everyone,

I'm trying to find a way to prevent recursive calls to On_change functions.

Here is the situation : I have 4 fields : cost, price, margin, and coef which are related using these simple formulas : price = cost + margin coef = (price)/cost

Now I have defined 3 on_change fucntions (one for each field except cost) which updates the other fields. i.e. : on change(margin) will update price and coef, on_change(price) will update margin and coef, and on_change(coef)will update price and margin.

These 3 functions work correctly, however they trigger each other recursively and indefinitly ! Since on_change(margin) update price and coef, it will trigger on_change(coef) and on_change(price) etc, etc...

Is there a way to prevent this behaviour? Thank you.

===== FR =====

Bonjour à tous,

je recherche une solution pour eviter des appels récursifs sur des fonctions on_change.

La situation : J'ai 4 champs : cout, prix, marge et coef, ces 4 champs sont liés par les formules suivantes : prix = cout + marge coef = prix/cout

J'ai défini 3 fonctions on_change pour les champs prix, marge et coef de telle façon que ces 3 champs soient mis à jour. par exemple : on_change(marge) met a jour le prix et le coef, on_change(coef) met à jour le prix et la marge...

Les 3 fonctions fonctionnent correctement, hormis le fait qu'elles se déclenchent les uns les autres de façon récursive et infinie ! Puisque la fonction on_change(margin) met a jour les champs prix et coef, les deux fonctions on_chnage(prix) et on_chnage(coef) s'executent aussi, etc, etc....

Existe t il un moyen d'éviter ce comportement ? Merci d'avance !

0
leo
On 12/9/13, 9:41 PM

Update. I find the answer using the solution listed here :

h**p://help.openerp.com/question/24702/infinite-loop-with-on_change/

returning empty dict when nothing changes !

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

0 follower(s)

Stats

Asked: 12/6/13, 4:24 PM
Seen: 1141 times
Last updated: 3/16/15, 8:10 AM