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 d3795c39d34..4ee26fde712 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..cc19e9d6007 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -296,7 +296,7 @@ class mail_thread(osv.AbstractModel):
if f._type == 'many2one':
if not isinstance(v, browse_record):
v = self.pool[f._obj].browse(cr, SUPERUSER_ID, v)
- return v.name_get()[0][1]
+ return v
if f._type == 'selection':
# TODO get translated value
pass
@@ -327,17 +327,20 @@ class mail_thread(osv.AbstractModel):
for record, changed_fields in changes.items():
# TODO tpl changed_fields
+ subtype = False
chg = []
for f in changed_fields:
ci = tracked[f]
from_ = convert_for_display(record[f], ci.column)
to = convert_for_display(values[f], ci.column)
- chg.append((_t(ci), from_, to))
+ if to.__hasattr__('subtype'):
+ subtype = to.subtype
+ chg.append((_t(ci), from_.name_get()[0][1], to.name_get()[0][1]))
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..e8e22e5fb09 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')
@@ -1160,7 +1155,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
@@ -1288,24 +1282,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 08981bd126a..ee88595956a 100644
--- a/addons/project/project_data.xml
+++ b/addons/project/project_data.xml
@@ -30,30 +30,35 @@
1
Analysis
draft
+ project.mt_task_new
2
Specification
draft
+ project.mt_task_change
2
Design
open
+ project.mt_task_change
3
Negotiation
pending
+ project.mt_task_change
4
Development
+ project.mt_task_change
open
@@ -61,12 +66,14 @@
5
Testing
open
+ project.mt_task_change
6
Merge
open
+ project.mt_task_change
@@ -74,12 +81,14 @@
7
Done
done
+ project.mt_task_closed
7
Cancelled
cancelled
+ project.mt_task_canceled
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 8bb45ca6738..df2188be6b6 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -750,6 +750,7 @@
+