Files
odoo_source/addons/hr/models/models.py
T
Dharmraj Jhala 610ba98539 [FIX] mail, crm: do not display body in creation message when having a subtype
Right now on few business objects (like leads, invoices, tasks, helpdesk
tickets etc) creation message contains
  * subtype description;
  * generic creation message;

This looks like multiple creation message on chatter after creation of the
record as you generally have "Task Created - Task created" (subtype description
then generic message).

This happens when we provide custom subtype on creation by by overriding
`_creation_subtype` method.

This commit fixes the issue by only using provided creation subtype and
removing default body. If creation subtype is not provided default creation
message is posted as before.

In this commit we also fix subtype for Lead/Opportunity creation and make
it generic ('Lead/Opportunity created') to avoid inconsistent behavior.

Finally some cleaning is made in method naming. Semi followup of 92e9e84b63

LINKS

Task ID-2288458
PR odoo/odoo#56631
PR odoo/enterprise#12707

closes odoo/odoo#56688

X-original-commit: 2ebbeb4b5443c6405dd9a3b202a1eee9c5c67ebb
Related: odoo/enterprise#12728
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-28 07:59:24 +00:00

21 lines
891 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, tools, _
class BaseModel(models.AbstractModel):
_inherit = 'base'
def _alias_get_error_message(self, message, message_dict, alias):
if alias.alias_contact == 'employees':
email_from = tools.decode_message_header(message, 'From')
email_address = tools.email_split(email_from)[0]
employee = self.env['hr.employee'].search([('work_email', 'ilike', email_address)], limit=1)
if not employee:
employee = self.env['hr.employee'].search([('user_id.email', 'ilike', email_address)], limit=1)
if not employee:
return _('restricted to employees')
return False
return super(BaseModel, self)._alias_get_error_message(message, message_dict, alias)