[IMP] crm, hr, project, sales_team: mail-related fixes

- hr, project, sales_team: no subscribe on create

For header records like sales steam, project, jobs and department, do not
subscribe the creator. Indeed those objects allow to automatically follow
child records (opportunities, tasks, issues, applicants). However those
records are often created by IT / technical / administrators that should
not be followers of all child records. Therefore the no subscribe key
is added in context.

- crm: new lead subtype

The 'new' stage is based on the sequence only, not the probability. Indeed
a new lead does not have a probability of 0; otherwise it is already lost.
This commit is contained in:
Thibault Delavallée
2015-08-27 17:07:02 +02:00
parent e755791af8
commit 65dbf8f117
4 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -928,7 +928,7 @@ Update your business card, phone book, social media,... Send an email right now
return 'crm.mt_lead_won'
elif 'active' in init_values and record.probability == 0 and not record.active:
return 'crm.mt_lead_lost'
elif 'stage_id' in init_values and record.probability == 0 and record.stage_id and record.stage_id.sequence <= 1:
elif 'stage_id' in init_values and record.stage_id and record.stage_id.sequence <= 1:
return 'crm.mt_lead_create'
elif 'stage_id' in init_values:
return 'crm.mt_lead_stage'
+10
View File
@@ -3,6 +3,7 @@
import logging
from openerp import api
from openerp import SUPERUSER_ID
from openerp import tools
from openerp.modules.module import get_module_resource
@@ -103,6 +104,12 @@ class hr_job(osv.Model):
}, context=context)
return True
# TDE note: done in new api, because called with new api -> context is a
# frozendict -> error when tryign to manipulate it
@api.model
def create(self, values):
return super(hr_job, self.with_context(mail_create_nosubscribe=True)).create(values)
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
@@ -308,6 +315,9 @@ class hr_department(osv.osv):
return res
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
context['mail_create_nosubscribe'] = True
# TDE note: auto-subscription of manager done by hand, because currently
# the tracking allows to track+subscribe fields linked to a res.user record
# An update of the limited behavior should come, but not currently done.
+2 -1
View File
@@ -319,7 +319,8 @@ class project(osv.osv):
# Prevent double project creation when 'use_tasks' is checked + alias management
create_context = dict(context, project_creation_in_progress=True,
alias_model_name=vals.get('alias_model', 'project.task'),
alias_parent_model_name=self._name)
alias_parent_model_name=self._name,
mail_create_nosubscribe=True)
if vals.get('type', False) not in ('template', 'contract'):
vals['type'] = 'contract'
+6
View File
@@ -55,6 +55,12 @@ class crm_team(osv.Model):
(osv.osv._check_recursion, 'Error ! You cannot create recursive Sales team.', ['parent_id'])
]
def create(self, cr, uid, values, context=None):
if context is None:
context = {}
context['mail_create_nosubscribe'] = True
return super(crm_team, self).create(cr, uid, values, context=context)
def name_get(self, cr, uid, ids, context=None):
"""Overrides orm name_get method"""
if not isinstance(ids, list):