|
|
to_compute = self.filtered("activity_user_type")
(self - to_compute).activity_user_id = False
(self - to_compute).activity_user_field_name = False
for action in to_compute:
if action.activity_user_type == 'specific':
action.activity_user_field_name = False
else:
action.activity_user_id = False
IrModelFields = self.env['ir.model.fields']
domain = [('model', '=', action.model_id.model), ("relation", "=", "res.users")]
action.activity_user_field_name = (
IrModelFields.search([*domain, ("name", "=", "user_id")], limit=1)
or IrModelFields.search(domain, limit=1)
).name
|
|