Hello,
I would like to change my field "ferme" according to other field "client", these 2 fields are defined as follows :
ferme_name = fields.Many2one('gestion_parcelles.ferme', string="Nom de ferme", required=True, ondelete='cascade')
client = fields.Many2one('res.users', 'Vendu à Client Final')
The domain of the field "client" is changed according to this function :
def set_domain(self):
group = self.env.ref('affichage2.group_information_client')
users = []
for user in group.users:
if user.id != 1:
users.append(user.id)
return {'domain': {'client': [('id', 'in', users)]}}
And in the XML view :
<field name="client" on_change="set_domain()" />
The problem is that my field "ferme" don't change according the field "client", using the following function :
@api.onchange('client')
def set_values_ferme(self):
ids = self.env['gestion_parcelles.ferme'].search([('approved_by', '=', self.client)])
#self.ferme_name =ids.ids
res={}
res['domain'] = {'domain': [('ferme_name', 'in', ids.ids )] }
return(res)
Any help please ? Thank you in advance.