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

v8 How to decorate Computed fields methods depending on relation ?

By
Emanuel Cino
on 8/4/15, 6:03 AM 313 views

Let's say a computed field depends on a relation, like this:

event_year = fields.Date(compute='_get_event_year', store=True)

fiscal_years = fields.One2many('account.fiscal.year')

@api.depends('fiscal_years')
def _get_event_year(self):
...

Is it ok to depend only on field fiscal_years, i.e. will the year will be changed anytime one dependent fiscal_year is updated or should we specify each field on the relation we wan't to listen to like for instance 'fiscal_years.year' ? If we would listen to several fields like ('fiscal_years.year', 'fiscal_years.month', ...) can we just keep 'fiscal_years' in the depends decorator or should we list all sub_fields ? 

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: 8/4/15, 6:03 AM
Seen: 313 times
Last updated: 8/4/15, 6:03 AM