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.

32 lines
1.2 KiB

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