diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 368656224ac..d53f416a8eb 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -78,6 +78,7 @@ class crm_case_stage(osv.osv):
'state': fields.selection(AVAILABLE_STATES, 'Related Status', required=True,
help="The status of your document will automatically change regarding the selected stage. " \
"For example, if a stage is related to the status 'Close', when your document reaches this stage, it is automatically closed."),
+ 'subtype': fields.char('Related Subtype', size=64),
'case_default': fields.boolean('Common to All Teams',
help="If you check this field, this stage will be proposed by default on each sales team. It will not assign this stage to existing teams."),
'fold': fields.boolean('Hide in Views when Empty',
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 14cbb11f611..761afab6042 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -382,7 +382,6 @@ class crm_lead(base_stage, format_address, osv.osv):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0)], context=context)
if stage_id:
self.case_set(cr, uid, [lead.id], values_to_update={'probability': 0.0}, new_stage_id=stage_id, context=context)
- self.case_mark_lost_send_note(cr, uid, ids, context=context)
return True
def case_mark_won(self, cr, uid, ids, context=None):
@@ -391,7 +390,6 @@ class crm_lead(base_stage, format_address, osv.osv):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0)], context=context)
if stage_id:
self.case_set(cr, uid, [lead.id], values_to_update={'probability': 100.0}, new_stage_id=stage_id, context=context)
- self.case_mark_won_send_note(cr, uid, ids, context=context)
return True
def set_priority(self, cr, uid, ids, priority):
@@ -843,11 +841,6 @@ class crm_lead(base_stage, format_address, osv.osv):
# OpenChatter methods and notifications
# ----------------------------------------
- def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
- """ Override of the (void) default notification method. """
- stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
- return self.message_post(cr, uid, ids, body=_("Stage changed to %s.") % (stage_name), subtype="mt_crm_stage", context=context)
-
def case_get_note_msg_prefix(self, cr, uid, lead, context=None):
if isinstance(lead, (int, long)):
lead = self.browse(cr, uid, [lead], context=context)[0]
@@ -859,14 +852,6 @@ class crm_lead(base_stage, format_address, osv.osv):
self.message_post(cr, uid, [id], body=message, context=context)
return True
- def case_mark_lost_send_note(self, cr, uid, ids, context=None):
- message = _("Opportunity has been lost.")
- return self.message_post(cr, uid, ids, body=message, subtype="mt_crm_lost", context=context)
-
- def case_mark_won_send_note(self, cr, uid, ids, context=None):
- message = _("Opportunity has been won.")
- return self.message_post(cr, uid, ids, body=message, subtype="mt_crm_won", context=context)
-
def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None):
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0]
if action == 'log': prefix = 'Logged'
diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml
index b7541b6daf0..5490f590855 100644
--- a/addons/crm/crm_lead_data.xml
+++ b/addons/crm/crm_lead_data.xml
@@ -7,6 +7,7 @@
New
draft
+ mail.mt_crm_stage
both
@@ -15,6 +16,7 @@
Opportunity
open
+ mail.mt_crm_stage
lead
@@ -23,6 +25,7 @@
Qualification
open
+ mail.mt_crm_stage
opportunity
@@ -31,6 +34,7 @@
Proposition
open
+ mail.mt_crm_stage
opportunity
@@ -39,6 +43,7 @@
Negotiation
open
+ mail.mt_crm_stage
opportunity
@@ -47,6 +52,7 @@
Won
done
+ mail.mt_crm_won
@@ -57,6 +63,7 @@
cancel
+ mail.mt_crm_stage
lead
@@ -66,6 +73,7 @@
cancel
+ mail.mt_crm_lost
opportunity
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 99d3752529e..d6731f8f0bd 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -203,6 +203,7 @@
+
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 4d98ecbdc97..cf8dc453867 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -324,20 +324,32 @@ class mail_thread(osv.AbstractModel):
model = c.parent_model or self._name
lang = context.get('lang')
return Trans._get_source(cr, uid, '{0},{1}'.format(model, c.name), 'field', lang, ci.column.string)
+
+ def get_subtype(model, record):
+ record_model = self.pool[model].browse(cr, SUPERUSER_ID, record)
+ if record_model.__hasattr__('subtype'):
+ return record_model.subtype
+ return False
for record, changed_fields in changes.items():
# TODO tpl changed_fields
chg = []
+ subtype = False
for f in changed_fields:
ci = tracked[f]
from_ = convert_for_display(record[f], ci.column)
to = convert_for_display(values[f], ci.column)
+ if to is None:
+ to = "Removed"
+ if ci.column._type == "many2one":
+ subtype = get_subtype(ci.column._obj,values[f])
+
chg.append((_t(ci), from_, to))
message = MakoTemplate(self._TRACK_TEMPLATE).render_unicode(updated_fields=updated_fields,
changes=chg)
- record.message_post(message)
+ record.message_post(message,subtype=subtype)
return result
diff --git a/addons/project/project.py b/addons/project/project.py
index 7beef9e1050..7dff3fa28f5 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -46,6 +46,7 @@ class project_task_type(osv.osv):
'state': fields.selection(_TASK_STATE, 'Related Status', required=True,
help="The status of your document is automatically changed regarding the selected stage. " \
"For example, if a stage is related to the status 'Close', when your document reaches this stage, it is automatically closed."),
+ 'subtype': fields.char('Related Subtype', size=64),
'fold': fields.boolean('Hide in views if empty',
help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."),
}
@@ -993,14 +994,12 @@ class task(base_stage, osv.osv):
if not task.date_end:
vals['date_end'] = fields.datetime.now()
self.case_set(cr, uid, [task.id], 'done', vals, context=context)
- self.case_close_send_note(cr, uid, [task.id], context=context)
return True
def do_reopen(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids, context=context):
project = task.project_id
self.case_set(cr, uid, [task.id], 'open', {}, context=context)
- self.case_open_send_note(cr, uid, [task.id], context)
return True
def do_cancel(self, cr, uid, ids, context=None):
@@ -1012,7 +1011,6 @@ class task(base_stage, osv.osv):
self._check_child_task(cr, uid, ids, context=context)
for task in tasks:
self.case_set(cr, uid, [task.id], 'cancelled', {'remaining_hours': 0.0}, context=context)
- self.case_cancel_send_note(cr, uid, [task.id], context=context)
return True
def do_open(self, cr, uid, ids, context=None):
@@ -1022,7 +1020,6 @@ class task(base_stage, osv.osv):
def case_open(self, cr, uid, ids, context=None):
if not isinstance(ids,list): ids = [ids]
self.case_set(cr, uid, ids, 'open', {'date_start': fields.datetime.now()}, context=context)
- self.case_open_send_note(cr, uid, ids, context)
return True
def do_draft(self, cr, uid, ids, context=None):
@@ -1031,7 +1028,6 @@ class task(base_stage, osv.osv):
def case_draft(self, cr, uid, ids, context=None):
self.case_set(cr, uid, ids, 'draft', {}, context=context)
- self.case_draft_send_note(cr, uid, ids, context=context)
return True
def do_pending(self, cr, uid, ids, context=None):
@@ -1039,8 +1035,7 @@ class task(base_stage, osv.osv):
return self.case_pending(cr, uid, ids, context=context)
def case_pending(self, cr, uid, ids, context=None):
- self.case_set(cr, uid, ids, 'pending', {}, context=context)
- return self.case_pending_send_note(cr, uid, ids, context=context)
+ return self.case_set(cr, uid, ids, 'pending', {}, context=context)
def _delegate_task_attachments(self, cr, uid, task_id, delegated_task_id, context=None):
attachment = self.pool.get('ir.attachment')
@@ -1080,7 +1075,6 @@ class task(base_stage, osv.osv):
self.do_pending(cr, uid, [task.id], context=context)
elif delegate_data['state'] == 'done':
self.do_close(cr, uid, [task.id], context=context)
- self.do_delegation_send_note(cr, uid, [task.id], context)
delegated_tasks[task.id] = delegated_task_id
return delegated_tasks
@@ -1160,7 +1154,6 @@ class task(base_stage, osv.osv):
self._subscribe_project_followers_to_task(cr, uid, task_id, context=context)
self._store_history(cr, uid, [task_id], context=context)
- self.create_send_note(cr, uid, [task_id], context=context)
return task_id
# Overridden to reset the kanban_state to normal whenever
@@ -1178,7 +1171,6 @@ class task(base_stage, osv.osv):
#raise osv.except_osv(_('Warning!'), _('Stage is not defined in the project.'))
write_vals = vals_reset_kstate if t.stage_id != new_stage else vals
super(task, self).write(cr, uid, [t.id], write_vals, context=context)
- self.stage_set_send_note(cr, uid, [t.id], new_stage, context=context)
result = True
else:
result = super(task, self).write(cr, uid, ids, vals, context=context)
@@ -1288,24 +1280,8 @@ class task(base_stage, osv.osv):
res = super(task, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
return res + ['user_id', 'manager_id']
- def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
- """ Override of the (void) default notification method. """
- stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1]
- return self.message_post(cr, uid, ids, body=_("Stage changed to %s.") % (stage_name),
- context=context)
-
- def create_send_note(self, cr, uid, ids, context=None):
- return self.message_post(cr, uid, ids, body=_("Task has been created."), context=context)
-
- def case_draft_send_note(self, cr, uid, ids, context=None):
return self.message_post(cr, uid, ids, body=_('Task has been set as draft.'), context=context)
- def do_delegation_send_note(self, cr, uid, ids, context=None):
- for task in self.browse(cr, uid, ids, context=context):
- msg = _('Task has been delegated to %s.') % (task.user_id.name)
- self.message_post(cr, uid, [task.id], body=msg, context=context)
- return True
-
def project_task_reevaluate(self, cr, uid, ids, context=None):
if self.pool.get('res.users').has_group(cr, uid, 'project.group_time_work_estimation_tasks'):
return {
diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml
index 4d4ead3e90e..e6cd419e201 100644
--- a/addons/project/project_data.xml
+++ b/addons/project/project_data.xml
@@ -30,11 +30,13 @@
1
Analysis
draft
+ project.mt_task_new
2
Specification
+ project.mt_task_change
pending
@@ -42,11 +44,13 @@
2
Design
open
+ project.mt_task_change
3
Development
+ project.mt_task_change
open
@@ -54,12 +58,14 @@
4
Testing
open
+ project.mt_task_change
5
Merge
open
+ project.mt_task_change
@@ -67,6 +73,7 @@
6
Done
done
+ project.mt_task_closed
@@ -74,6 +81,7 @@
7
Cancelled
cancelled
+ project.mt_task_canceled
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index f54fb20ea20..0cc82415036 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -746,6 +746,7 @@
+