Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Automation Rules

Entity: base.automation

Compute Method: _compute_trigger_field_ids

View 17.0 View 20.0
Inputs Method Outputs
  • model_id
  • model_id.id
  • trigger
  • model_id.is_mail_thread
  • trigger_field_ids
- for automation in self:
-             domain = [('model_id', '=', automation.model_id.id)]
-             if automation.trigger == 'on_stage_set':
-                 domain += [('ttype', '=', 'many2one'), ('name', 'in', ['stage_id', 'x_studio_stage_id'])]
-             elif automation.trigger == 'on_tag_set':
-                 domain += [('ttype', '=', 'many2many'), ('name', 'in', ['tag_ids', 'x_studio_tag_ids'])]
-             elif automation.trigger == 'on_priority_set':
-                 domain += [('ttype', '=', 'selection'), ('name', 'in', ['priority', 'x_studio_priority'])]
-             elif automation.trigger == 'on_state_set':
-                 domain += [('ttype', '=', 'selection'), ('name', 'in', ['state', 'x_studio_state'])]
-             elif automation.trigger == 'on_user_set':
-                 domain += [
-                     ('relation', '=', 'res.users'),
-                     ('ttype', 'in', ['many2one', 'many2many']),
-                     ('name', 'in', ['user_id', 'user_ids', 'x_studio_user_id', 'x_studio_user_ids']),
-                 ]
-             elif automation.trigger in ['on_archive', 'on_unarchive']:
-                 domain += [('ttype', '=', 'boolean'), ('name', 'in', ['active', 'x_active'])]
-             elif automation.trigger == 'on_time_created':
-                 domain += [('ttype', '=', 'datetime'), ('name', '=', 'create_date')]
-             elif automation.trigger == 'on_time_updated':
-                 domain += [('ttype', '=', 'datetime'), ('name', '=', 'write_date')]
-             else:
-                 automation.trigger_field_ids = False
-                 continue
-             if automation.model_id.is_mail_thread and automation.trigger in MAIL_TRIGGERS:
-                 continue
- 
-             automation.trigger_field_ids = self.env['ir.model.fields'].search(domain, limit=1)
-             automation.trigger = False if not automation.trigger_field_ids else automation.trigger
+ for rec in self.filtered(lambda a: a.trigger != "on_create_or_write"):
+             rec._onchange_trigger()
  • trigger_field_ids
  • trigger

Back to entity