Skip to Content
Menu
This question has been flagged
2 Replies
2312 Views

I have a problem with the many2many relationship in odoo 11.
Let say i have two models A and B defined as follow

class A(models.Model):      
    _name = 'module.A'      
    b_ids = fields.many2many('B')
class B(models.Model):      
    _name = 'module.B'
    def my_method(self):
        #my method

What i want to do in 'my_method' is to get the recordset of A model related to B's current record. How can i do that please?

Avatar
Discard
Best Answer

Hello lauris,

if you want to see relation of A and B into my_method by many2many then you can implement as:

my_method_m2m = fields.Many2many('module.A', '(Define name for relation)_rel', 'column of table A', 'column of table B')

i think it will help you

Avatar
Discard
Author Best Answer

Hello Pawan

Then how am i going the get the A's records related to B's current record being in 'my_method'?


Avatar
Discard