Odoo Help


How to know which field triggers an @api.depends?

Alejandro Santana
on 6/3/15, 6:10 PM 1,583 views

NOTE: This question is similar to this one, but its case is a different one with a completely different solution..

I have this situation:

field_1 has a compute method, which uses @api.depends('field_2', 'field_3').

But here comes the important part... the value given to field_1 depends on which field (field_2 or field_3) is modified by ORM (thus triggering the @api.depends).

Is there a way to know which field triggers a multi-triggered @api.depends?

I know I can capture that overriding write, but I would like to be reflected in view.

And I could use a onchange on field_2 and another on field_3, but then it would only be useful in views, no in ORM modifications.

Ankit Gauri
On 6/4/15, 6:24 AM


its not possible

I feared so. So I solved it with an aid field, @api.depends, @api.onchange, write and create override.

Anubía, soluciones en la nube, S.L., Alejandro Santana
on 6/4/15, 6:42 AM

@ Alejandro Santana Okay

Ankit Gauri
on 6/4/15, 6:44 AM

You could have a common method and control based on field triggered

 def main_method(self, field_triggered):
# Control with field_triggered field value
#     ....

def field1_trigger(self):

def field2_trigger(self):

OK, I would like to use @api.depends instead of @api.onchange (to get changes in ORM, not only in vies), but I guess it could be. The thing is: you propose I use "compute='main_method'" in my field, but actually triggered with any other methods. Am I right? Mmm... I have to test it.

Anubía, soluciones en la nube, S.L., Alejandro Santana
on 6/9/15, 6:39 AM

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 6/3/15, 6:10 PM
Seen: 1583 times
Last updated: 6/5/15, 1:30 AM