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 have created a many2many relationship via Python code between partners to allow partner A to have more than one associated company B & C for example.
Now, if I go to partner B or C, I am expecting to see A; but, this is not the case.
I think this behavior is normal; because I only added the records for B & C under A and not the other way around.
Any idea how I can make this happen the other way around?
Thanks in advance.
In Odoo7 you can use the "fields.related" type of fields.
In Odoo8 the "fields.related" are replaced with attributes on the relations fields (one2many, many2one and many2many). The parameters are "related=". Following is example of the related field:
Here is the syntax for many2many:-
field_name = fields.Many2many ( 'res.partner.category', 'res_partner_category_rel', 'partner_id', 'category_id', 'Categories'),
Example with book and author:-
book_ids = fields.Many2many('op.book', 'book_author_rel', 'op_author_id', 'op_book_id', string='Books'),
author_ids = fields.Many2many('op.author', 'book_author_rel', 'op_book_id', 'op_author_id', string='Author'),
And you can link between both books and authors and its bidirectional.
Hope this helps...
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: 3/18/15, 12:19 AM|
|Seen: 2035 times|
|Last updated: 3/18/15, 1:41 AM|