Skip to content
Permalink
Browse files

wip bring back track template

  • Loading branch information...
Xavier-Do committed Mar 19, 2019
1 parent fef80c0 commit 320f324a36bee0995bb8be6a4e4bc77edde84602
@@ -348,10 +348,9 @@ def action_applications_email(self):
}

@api.multi
def _track_template(self, tracking):
res = super(Applicant, self)._track_template(tracking)
def _track_template(self, changes):
res = super(Applicant, self)._track_template(changes)
applicant = self[0]
changes, dummy = tracking[applicant.id]
if 'stage_id' in changes and applicant.stage_id.template_id:
res['stage_id'] = (applicant.stage_id.template_id, {
'auto_delete_message': True,
@@ -291,6 +291,15 @@ def create(self, vals_list):
else:
thread._message_log(body=body) # todo optimise email_from

if not self._context.get('mail_notrack'):
if 'lang' not in self._context:
track_threads = threads.with_context(lang=self.env.user.lang)
else:
track_threads = threads
for thread, values in zip(track_threads, vals_list):
changes = set(key for (key, value) in enumerate(values) if value)
thread._message_track_post_template(changes)

return threads

def _creation_subtype(self):
@@ -322,8 +331,10 @@ def write(self, values):

# Perform the tracking
if tracked_fields:
track_self.with_context(clean_context(self._context)).message_track(tracked_fields, initial_values)

tracking = track_self.with_context(clean_context(self._context)).message_track(tracked_fields, initial_values)
if any(change for rec_id, (change, tracking_value_ids) in tracking.items()):
(changes, tracking_value_ids) = tracking[track_self[0].id]
track_self._message_track_post_template(changes)
return result

@api.multi
@@ -566,14 +577,14 @@ def _track_subtype(self, init_values):
return False

@api.multi
def _track_template(self, tracking):
def _track_template(self, changes):
return dict()

@api.multi
def _message_track_post_template(self, tracking):
if not any(change for rec_id, (change, tracking_value_ids) in tracking.items()):
def _message_track_post_template(self, changes):
if not changes:
return True
templates = self._track_template(tracking)
templates = self._track_template(changes)
for field_name, (template, post_kwargs) in templates.items():
if not template:
continue
@@ -649,9 +660,7 @@ def message_track(self, tracked_fields, initial_values):
elif tracking_value_ids:
record._message_log(tracking_value_ids=tracking_value_ids)

self._message_track_post_template(tracking)

return True
return tracking

# ------------------------------------------------------
# Email Notification
@@ -745,10 +745,9 @@ def _subtask_values_from_parent(self, parent_id):
# ---------------------------------------------------

@api.multi
def _track_template(self, tracking):
res = super(Task, self)._track_template(tracking)
def _track_template(self, changes):
res = super(Task, self)._track_template(changes)
test_task = self[0]
changes, tracking_value_ids = tracking[test_task.id]
if 'stage_id' in changes and test_task.stage_id.mail_template_id:
res['stage_id'] = (test_task.stage_id.mail_template_id, {
'auto_delete_message': True,
@@ -66,10 +66,9 @@ class MailTestFull(models.Model):
user_id = fields.Many2one('res.users', 'Responsible', tracking=1)
umbrella_id = fields.Many2one('mail.test', tracking=True)

def _track_template(self, tracking):
res = super(MailTestFull, self)._track_template(tracking)
def _track_template(self, changes):
res = super(MailTestFull, self)._track_template(changes)
record = self[0]
changes, tracking_value_ids = tracking[record.id]
if 'customer_id' in changes and record.mail_template:
res['customer_id'] = (record.mail_template, {'composition_mode': 'mass_mail'})
elif 'datetime' in changes:
@@ -134,10 +134,9 @@ def _read_group_stage_ids(self, stages, domain, order):
return stages.search([], order=order)

@api.multi
def _track_template(self, tracking):
res = super(Track, self)._track_template(tracking)
def _track_template(self, changes):
res = super(Track, self)._track_template(changes)
track = self[0]
changes, tracking_value_ids = tracking[track.id]
if 'stage_id' in changes and track.stage_id.mail_template_id:
res['stage_id'] = (track.stage_id.mail_template_id, {
'composition_mode': 'comment',

0 comments on commit 320f324

Please sign in to comment.
You can’t perform that action at this time.