I am currently developing an odoo12ce module which must contains a table with dogs registers and its father and mother of the dogs (something like a purebred). In the field father_code I want to get just the male dogs and the ones who live in the same city.
get_domain_male(self):
return [('gender', '=', 'male'), ('city', '=', self.city)]
father_code = fields.Many2one('asc.dog', string="Fathers code", domain = get_domain_male)
asc.dog is the same model, it means that the model is auto-referenced.
When I run the snippet, the city is already set and the field does not show anything, because self is not recognized as expected. When I print it, it is just False and the code run before I enter to the form view.
What could be wrong with the code and there is another way to filter it?? Thanks in advance for your help.