Odoo Help

0

How can I relate product to another using many2many both ways?

By
X0Rchid
on 9/30/14, 10:25 AM 774 views

I'm developing a module that should add a field Related Products. I added a many2many field

class product_template(osv.Model):
    _name = 'product.template'
    _inherit = 'product.template'
    _columns = {
        'related_products': fields.many2many('product.template', 'rel_related_product', 'product_id', string="Related Products"),
    }

The problem is that I can relate the product only one way. I.e. if I relate ProductB to ProductA, I can only see the relationship inside ProductA and not the otherway around

How can I solve that?

AFAIK you've to add relation fields in both classes, further check if you've to use the same helper table or different ones in both modules ( 'rel_related_product' ?) and you're missing 'other.object.id' in a definition. please refer to documentation.

Temur
on 9/30/14, 10:37 AM
0

deep

--deep--
1695
| 5 5 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 10/1/14, 1:37 AM

You cant relate it like that .... In Product A, you have related Product B, and reverse wont apply for Product B...

Alternate option, along with M2M column, try having a functional field of type M2M, in that function fetch to & fro records pertaining to that product A...

And in your syntax, target object id is missing too...

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

Question tools

2 follower(s)

Stats

Asked: 9/30/14, 10:25 AM
Seen: 774 times
Last updated: 3/16/15, 8:10 AM