diff --git a/tracking_manager/models/models.py b/tracking_manager/models/models.py index 484aefc0445..db10d860849 100644 --- a/tracking_manager/models/models.py +++ b/tracking_manager/models/models.py @@ -49,13 +49,22 @@ def _tm_notify_owner(self, mode, changes=None): ) for field_name, owner_field_name in self._tm_get_fields_to_notify(): owner = self[field_name] - data[owner._name][owner.id][owner_field_name].append( - { - "mode": mode, - "record": self.display_name, - "changes": changes, - } - ) + model_name = target_id = False + if isinstance(owner, models.BaseModel): + model_name = owner._name + target_id = owner.id + # In case of specific O2M (ex: ir.attachment with res_id) + elif isinstance(owner, int) and hasattr(self, "res_model"): + model_name = self.res_model + target_id = owner + if model_name and target_id: + data[model_name][target_id][owner_field_name].append( + { + "mode": mode, + "record": self.display_name, + "changes": changes, + } + ) def _tm_get_field_description(self, field_name): return self._fields[field_name].get_description(self.env)["string"]