You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

  1. from odoo import models, api
  2. class MailThread(models.AbstractModel):
  3. _inherit = 'mail.thread'
  4. @api.multi
  5. def _message_track(self, tracked_fields, initial):
  6. """For a given record, fields to check (column name, column info)
  7. and initial values, return a structure that is a tuple containing :
  8. - a set of updated column names
  9. - a list of changes (old value, new value, column name, column info)
  10. """
  11. changes = super(MailThread, self)._message_track(
  12. tracked_fields, initial)[0]
  13. tracking_value_ids = []
  14. track_obj = self.env['mail.tracking.value']
  15. for col_name, col_info in tracked_fields.items():
  16. initial_value = initial[col_name]
  17. new_value = getattr(self, col_name)
  18. if new_value != initial_value and (new_value or initial_value):
  19. track_sequence = getattr(
  20. self._fields[col_name], 'track_sequence', 100)
  21. tracking = track_obj.create_tracking_values(
  22. initial_value, new_value, col_name,
  23. col_info, track_sequence)
  24. if tracking:
  25. tracking_value_ids.append([0, 0, tracking])
  26. return changes, tracking_value_ids