Odoo Help


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.


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

Alejandro Santana
on 6/3/15, 6:10 PM 739 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

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 6/5/15, 1:29 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

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

2 follower(s)


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