[FIX] crm, hr_recruitment, project_issue: responsible
When using the mailgateway, the responsible of the newly created lead / applicant / issue is explicitely set to False since the original mailgateway commit in 2010. However this conflicts with some custom behavior that tries to set the responsible on the same objects. Notably in recruitment the responsible is set to be the recruitment responsible set on the job, if any. In this commit we replace the explicit set of user_id=False to using a default_user_id=False in the context. This way the admin or mailgateway user will not be responsible of every new records. And this enables custom behavior to find a responsible.
This commit is contained in:
@@ -1022,6 +1022,12 @@ Update your business card, phone book, social media,... Send an email right now
|
||||
through message_process.
|
||||
This override updates the document according to the email.
|
||||
"""
|
||||
# remove default author when going through the mail gateway. Indeed we
|
||||
# do not want to explicitly set user_id to False; however we do not
|
||||
# want the gateway user to be responsible if no other responsible is
|
||||
# found.
|
||||
create_context = dict(context or {})
|
||||
create_context['default_user_id'] = False
|
||||
if custom_values is None:
|
||||
custom_values = {}
|
||||
defaults = {
|
||||
@@ -1029,14 +1035,13 @@ Update your business card, phone book, social media,... Send an email right now
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'partner_id': msg.get('author_id', False),
|
||||
'user_id': False,
|
||||
}
|
||||
if msg.get('author_id'):
|
||||
defaults.update(self.on_change_partner_id(cr, uid, None, msg.get('author_id'), context=context)['value'])
|
||||
if msg.get('priority') in dict(crm_stage.AVAILABLE_PRIORITIES):
|
||||
defaults['priority'] = msg.get('priority')
|
||||
defaults.update(custom_values)
|
||||
return super(crm_lead, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
||||
return super(crm_lead, self).message_new(cr, uid, msg, custom_values=defaults, context=create_context)
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
|
||||
""" Overrides mail_thread message_update that is called by the mailgateway
|
||||
|
||||
@@ -392,13 +392,17 @@ class Applicant(models.Model):
|
||||
through message_process.
|
||||
This override updates the document according to the email.
|
||||
"""
|
||||
# remove default author when going through the mail gateway. Indeed we
|
||||
# do not want to explicitly set user_id to False; however we do not
|
||||
# want the gateway user to be responsible if no other responsible is
|
||||
# found.
|
||||
self = self.with_context(default_user_id=False)
|
||||
val = msg.get('from').split('<')[0]
|
||||
defaults = {
|
||||
'name': msg.get('subject') or _("No Subject"),
|
||||
'partner_name': val,
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
'partner_id': msg.get('author_id', False),
|
||||
}
|
||||
if msg.get('priority'):
|
||||
|
||||
@@ -394,6 +394,12 @@ class project_issue(osv.Model):
|
||||
through message_process.
|
||||
This override updates the document according to the email.
|
||||
"""
|
||||
# remove default author when going through the mail gateway. Indeed we
|
||||
# do not want to explicitly set user_id to False; however we do not
|
||||
# want the gateway user to be responsible if no other responsible is
|
||||
# found.
|
||||
create_context = dict(context or {})
|
||||
create_context['default_user_id'] = False
|
||||
if custom_values is None:
|
||||
custom_values = {}
|
||||
context = dict(context or {}, state_to='draft')
|
||||
@@ -402,11 +408,10 @@ class project_issue(osv.Model):
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'partner_id': msg.get('author_id', False),
|
||||
'user_id': False,
|
||||
}
|
||||
defaults.update(custom_values)
|
||||
|
||||
res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
||||
res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=defaults, context=create_context)
|
||||
email_list = self.email_split(cr, uid, [res_id], msg, context=context)
|
||||
partner_ids = filter(None, self._find_partner_from_emails(cr, uid, [res_id], email_list, force_create=False, context=context))
|
||||
self.message_subscribe(cr, uid, [res_id], partner_ids, context=context)
|
||||
|
||||
Reference in New Issue
Block a user