Hello,
I have Many2one field with domain function,
port_chargement_id = fields.Many2one('res.port', string='POL', domain=lambda self: self._get_port_chargement_domain())
def _get_port_chargement_domain(self):
domain = [('desservi', '=', True)]
if self.sens_fret_id.id == 1:
domain.append(('pays_id.code', 'not ilike', 'dz'))
if self.sens_fret_id.id == 2:
domain.append(('pays_id.code', 'ilike', 'dz'))
return domain
From the function I tried to get the current item field with the self.sens_fret , but the self.xxxxx doesn't work and it returns always False, i even tried with self.name
Hey salah! if you want to do these kind of stuff in on_change method than have a look it will help you: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html
Thanks! but in my case, the sens_fret_id field will be readonly in the next stage, so the port_chargement_id will always depend on the value selected previoulsly. so the onchange function will not be usefull.