Let's see the classic example of a related field: you have an object city, which has a field state_id, and you need to show its country.
The object city has a field state_id, which is a many2one, and the object state has a field country_id, which is also a many2one.
Now, what would happen if the type of the field state_id were one2many (and the type of country_id kept being many2one)? How should I declare the related field country_id?
This is obviously a nosense with those fields, but it's only an example to make easier to understand my question.
If `state_id` was a `one2many` you could keep exactly the same syntax and it would work. The behavior for `fields.related` when going though a *2many relationship is to take the first record found (depending on the order of the target model), and then to continue. As to whether this makes any sense, it very much depends on the use case. It makes a bit more sense for read-only access than for changes through the related fields.
True, If you establish a related relation for One2many field would be indeed nonsense...
O2M of state is nothing but list of Records, and you establish a related for it which will be a single field, so resultant value will keep overriding with latest records ie states' country.. which is utterly meaningless..
Techincally speaking, this must be a bug, guess some how Odoo guys have overlooked this....
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
|Asked: 10/15/14, 5:43 AM|
|Seen: 1476 times|
|Last updated: 3/16/15, 8:10 AM|