This question has been flagged
1 Reply
4301 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?

Avatar
Discard

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.

Best Answer

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...

Avatar
Discard