Help

0

When update/insert data one model also update/insert another model

Avatar
ViewPoints

I have two model, when I change one model another one will change automatically.

class ModelA(models.Model):
    _name = 'res.partner'
    user_id = fields.Many2one('res.users',string='Sales Person')
    
class ModelB(models.Model):
    _name = 'res.users'
    agent_id = fields.Many2one('res.users', string='Ref Agent')
Avatar
Discard
1 Answer
1
Avatar
Kamrul Hasan
Best Answer

You can try related field .

class ModelA(models.Model):
    _name = 'res.partner'
    user_id = fields.Many2one('res.users',string='Sales Person')
    
class ModelB(models.Model):
    _name = 'res.users'
    agent_id = fields.Many2one("res.users", "Ref Agent", related='partner_id.user_id')
Avatar
Discard