Im new to odoo. Im using odoo 13 and I have a many2one field and a many2many field with domain on the many2one field. What I need is that if the user changes the many2one field the many2many gets empty and ready to choose. but I don't know how to code that on a function so I have tried some variants but it just dont come to me. If I use this I just get an error when Im going to select for the first time the 'industria' field
class Partner(models.Model):
_inherit = 'res.partner'
industria = fields.Many2one('industria_model', string="Industria")
marca = fields.Many2many('marca_model',
domain="[('industria_id', '=', industria)]", string="Marca")
@api.onchange('industria')
def get_price(self):
self.marca = [(5)]
# if self.marca:
# self.marca = [(5, 0, 0)]
marca = False
,marca = [(6, 0, [])]
,marca = []
I think all of this works as I remember – Charif DZ