Hi, I’m trying to obtain fields of the parent in
on_change_with however I keep getting None. I’ve tried the answer from On_change on a selection field inside a one2many field but I still can’t seem to obtain the value of the parent field.
In my parent.py, I have the following fields
pharmacy = fields.Many2One( 'party.party', 'Pharmacy') child= fields.One2Many( 'prescriptions.child', 'name', 'Prescriptions')
In my child.py
pharmacy_location = fields.Integer("Pharmacy Location") @fields.depends('DependingOnChangeField','_parent_pharmacy','pharmacy_location') def on_change_with_pharmacy_location(self): return self._parent_pharmacy.id
When I create a new child and modify
DependingOnChangeField, this results in an exception as
_parent_pharmacy does not exist in the model, and I checked
self and they are both None as well
Am I missing something here or is there any other ways to obtain parent field values? It doesn’t necessarily have to be in
on_change_with, as my main purpose is to obtain the parent field values when I create a new child or edit existing child, not to update the value of pharmacy_location.