Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I created a stored (stored=True) computed field.
When field related to this one are modified, I want to change the value of the field.
So I used @api.depense, as follow :
@api.multi @api.depends('lst_price','price','taxes_id','price_extra_ttc','price_extra') def _product_price_ttc(self):
for record in self:
record.price_ttc = round(record.lst_price * ( 1 + record.taxes_id.amount),2)
But when one the field of the 'depends' if modified, my function does not fire.
What is wrong with my code ?
Finally the solution was : display the api.depends fields on the same page than price_ttc, so when those field are not on the same page that price_ttc, even if I update them, It's not working.
I'm a bit desapointed : I thought that api.depends was working everywhere at every moment, but nope. All the fields must be in the same view than the modified one :(
your function (that computes a field) will fire when you access the computed field (either when field is displayed in UI somewhere or included in UI as invisible or you access field from code using "my_browserecord.my_field", etc...) and NOT otherwise. There is nothing wrong with your code, just wrong expectation about when it should be fired.
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 6/19/15, 5:06 AM|
|Seen: 5827 times|
|Last updated: 1/16/18, 5:11 PM|