diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 238029a3f58..e1fa87d2e5b 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -122,7 +122,9 @@ class crm_case_section(osv.osv): 'note': fields.text('Description'), 'working_hours': fields.float('Working Hours', digits=(16,2 )), 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True, + help="This Unique Mail Box Alias of the Sales Team allows to manage the Seamless email communication between Mail Box and OpenERP," + "This Alias MailBox also create and Manage the new Email Leads for this Sales Team and also manage the existing Lead email communication."), } def _get_stage_common(self, cr, uid, context): @@ -172,19 +174,13 @@ class crm_case_section(osv.osv): return res def create(self, cr, uid, vals, context=None): - model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') if not vals.get('alias_id'): - model, res_id = model_pool.get_object_reference( cr, uid, "crm", "model_crm_lead") - vals.update({'alias_name': "sales", - 'alias_model_id': res_id}) - alias_pool.create_unique_alias(cr, uid, vals, context=context) - res = super(crm_case_section, self).create(cr, uid, vals, context) - record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':record['id'],'type':'lead'}},context) - return res - return super(crm_case_section, self).create(cr, uid, vals, context) - + alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': "sales_team."+vals['name'], 'alias_model_id': self._name}, context=context) + vals.update({'alias_id': alias_id}) + res = super(crm_case_section, self).create(cr, uid, vals, context) + alias_pool.write(cr, uid, [vals['alias_id']],{'alias_defaults':{'section_id': res,'type':'lead'}},context) + return res class crm_case_categ(osv.osv): """ Category of Case """ diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index d000c0c07ae..a7b2b9dc45b 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -552,7 +552,9 @@ class hr_job(osv.osv): _inherits = {'mail.alias': 'alias_id'} _columns = { 'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True, + help="This Unique Mail Box Alias of the Job allows to manage the Seamless email communication between Mail Box and OpenERP," + "This Alias MailBox also create and Manage the new Email applicant for this job and also manage the existing applicant email communication."), } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): @@ -568,17 +570,13 @@ class hr_job(osv.osv): return res def create(self, cr, uid, vals, context=None): - model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') - res_id = model_pool.get_object( cr, uid, "hr_recruitment", "model_hr_applicant") - vals.update({'alias_name': "job", - 'alias_model_id': res_id.id}) - alias_pool.create_unique_alias(cr, uid, vals, context=context) + if not vals.get('alias_id'): + alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': "job."+vals['name'], 'alias_model_id': self._name}, context=context) + vals.update({'alias_id': alias_id}) res = super( hr_job, self).create(cr, uid, vals, context) - record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']], {"alias_defaults": {'job_id': record['id']}}, context) + alias_pool.write(cr, uid, [vals['alias_id']], {"alias_defaults": {'job_id': res}}, context) return res - def action_print_survey(self, cr, uid, ids, context=None): if context is None: diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index aed3fe1667e..f073b85ffad 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -451,7 +451,7 @@ - Jobs + jobs {} diff --git a/addons/hr_recruitment/hr_recruitment_demo.yml b/addons/hr_recruitment/hr_recruitment_demo.yml index c616e9e7e95..7ec4efa7df7 100644 --- a/addons/hr_recruitment/hr_recruitment_demo.yml +++ b/addons/hr_recruitment/hr_recruitment_demo.yml @@ -1,6 +1,6 @@ - !record {model: mail.alias, id: alias_job_devloper, view: False}: - alias_name: 'job-developer' + alias_name: 'job_developer' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -12,7 +12,7 @@ alias_id: alias_job_devloper - !record {model: mail.alias, id: alias_job_ceo, view: False}: - alias_name: 'job-ceo' + alias_name: 'job_ceo' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -24,7 +24,7 @@ alias_id: alias_job_ceo - !record {model: mail.alias, id: alias_job_cto, view: False}: - alias_name: 'job-cto' + alias_name: 'job_cto' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -36,7 +36,7 @@ alias_id: alias_job_cto - !record {model: mail.alias, id: alias_job_hr_manager, view: False}: - alias_name: 'job-hr-manager' + alias_name: 'job_hr_manager' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -48,7 +48,7 @@ alias_id: alias_job_hr_manager - !record {model: mail.alias, id: alias_job_consultant, view: False}: - alias_name: 'job-consultant' + alias_name: 'job_consultant' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -60,7 +60,7 @@ alias_id: alias_job_consultant - !record {model: mail.alias, id: alias_job_hrm, view: False}: - alias_name: 'job-hrm' + alias_name: 'job_hrm' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -72,7 +72,7 @@ alias_id: alias_job_hrm - !record {model: mail.alias, id: alias_job_marketing, view: False}: - alias_name: 'job-marketing' + alias_name: 'job_marketing' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -84,7 +84,7 @@ alias_id: alias_job_marketing - !record {model: mail.alias, id: alias_job_trainee, view: False}: - alias_name: 'job-trainees' + alias_name: 'job_trainees' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 06d24fca006..71c1c033142 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -132,12 +132,13 @@ class mail_alias(osv.Model): @return int: New alias_id """ model_pool = self.pool.get('ir.model') - values = {'alias_name': vals['alias_name']} + alias_name = vals['alias_name'] + values = {'alias_name': alias_name} #Find for the mail alias exist or not if exit then get new mail address. if self.search(cr, uid, [('alias_name', '=', vals['alias_name'])]): - values.update({'alias_name': self._generate_alias(cr, uid, vals['alias_name'], sequence=1, context=context)}) - alias_name = re.sub(r'[^a-zA-Z0-9:]', '_', values['alias_name']).lower() - values.update({'alias_name': alias_name}) + alias_name = self._generate_alias(cr, uid, vals['alias_name'], sequence=1, context=context) + alias_name = re.sub(r'\W+', '_', alias_name) + values.update({'alias_name': alias_name.lower()}) #Set the model fo rhte mail alias model_sids = model_pool.search(cr, uid, [('model', '=', vals['alias_model_id'])]) values.update({'alias_model_id': model_sids[0]}) diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 5688e78255b..5b01968ed5e 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -130,7 +130,9 @@ class mail_group(osv.osv): 'member_count': fields.function(get_member_ids, type='integer', string='Member count', multi='get_member_ids'), 'is_subscriber': fields.function(get_member_ids, type='boolean', string='Joined', multi='get_member_ids'), 'last_month_msg_nbr': fields.function(get_last_month_msg_nbr, type='integer', string='Messages count for last month'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True) + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True, + help="This Unique Mail Box Alias of the Group allows to manage the Seamless email communication between Mail Box and OpenERP," + "This Alias MailBox manage the Group email communication.") } _defaults = { diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 702c36cfe37..e30f84fc70e 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -40,7 +40,9 @@ class res_users(osv.osv): ('none', 'Never') ], 'Receive Feeds by Email', required=True, help="Choose in which case you want to receive an email when you receive new feeds."), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True, + help="This Unique Mail Box Alias of the User allows to manage the Seamless email communication between Mail Box and OpenERP," + "This Alias MailBox manage the Users email communication."), } _defaults = { @@ -73,7 +75,7 @@ class res_users(osv.osv): def create(self, cr, uid, data, context=None): # create default alias same as the login alias_pool = self.pool.get('mail.alias') - alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': data['name'], 'alias_model_id': self._name}, context=context) + alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': data['login'], 'alias_model_id': self._name}, context=context) data.update({'alias_id': alias_id}) user_id = super(res_users, self).create(cr, uid, data, context=context) alias_pool.write(cr, uid, [alias_id], {"alias_force_thread_id": user_id}, context) @@ -89,7 +91,7 @@ class res_users(osv.osv): def write(self, cr, uid, ids, vals, context=None): # if login of user have been changed then change alias of user also. - if 'login' in vals.keys(): + if vals.get('login'): for user in self.browse(cr, uid, ids, context=context): self.pool.get('mail.alias').write(cr, uid, [user.alias_id.id], {'alias_name': vals['login']}, context=context) return super(res_users, self).write(cr, uid, ids, vals, context=context) diff --git a/addons/project/project.py b/addons/project/project.py index aa32fbb16e2..8b678ae238c 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -165,7 +165,7 @@ class project(osv.osv): res[task.project_id.id] += 1 return res def _get_alias_model(self, cr, uid, context=None): - return [('model_project_task', "Tasks")] + return [('project.task', "Tasks")] def _get_followers(self, cr, uid, ids, name, arg, context=None): ''' @@ -217,8 +217,11 @@ class project(osv.osv): 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'task_count': fields.function(_task_count, type='integer', string="Open Tasks"), 'color': fields.integer('Color Index'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), - 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1", required=True), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True, + help="This Unique Mail Box Alias of the Project allows to manage the Seamless email communication between Mail Box and OpenERP," + "This Alias MailBox also create and Manage the new Email Tasks/Issues for this Project and also manage the existing Task/Issue email communication."), + 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1", required=True, + help="Allows to select Model for the Mail alias .Based on selected model Task/issue will created for fetched mails or it will maintain communication for related Task/Issue."), 'privacy_visibility': fields.selection([('public','Public'), ('followers','Followers Only')], 'Privacy / Visibility'), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), 'followers': fields.function(_get_followers, method=True, fnct_search=_search_followers, @@ -239,7 +242,7 @@ class project(osv.osv): 'priority': 1, 'sequence': 10, 'type_ids': _get_type_common, - 'alias_model':'model_project_task', + 'alias_model':'project.task', } # TODO: Why not using a SQL contraints ? @@ -521,15 +524,12 @@ def Project(): return self.pool.get('res.users').read(cr, uid, sub_ids, context=context) def create(self, cr, uid, vals, context=None): - model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') - model, res_id = model_pool.get_object_reference( cr, uid, "project", vals.get('alias_model','model_project_task')) - vals.update({'alias_name':"project", - 'alias_model_id': res_id}) - alias_pool.create_unique_alias(cr, uid, vals, context=context) + if not vals.get('alias_id'): + alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': "project."+vals['name'], 'alias_model_id': vals.get('alias_model','project.task')}, context=context) + vals.update({'alias_id': alias_id}) res = super( project, self).create(cr, uid, vals, context) - record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']], {'alias_defaults':{'project_id': record['id']}}, context) + alias_pool.write(cr, uid, [vals['alias_id']], {'alias_defaults':{'project_id': res}}, context) self.create_send_note(cr, uid, [res], context=context) return res @@ -553,16 +553,15 @@ def Project(): return self.message_append_note(cr, uid, ids, body=message, context=context) def write(self, cr, uid, ids, vals, context=None): - model_pool = self.pool.get('ir.model.data') + model_pool = self.pool.get('ir.model') alias_pool = self.pool.get('mail.alias') # if alias_model have been changed then change alias_model_id of alias also. if vals.get('alias_model'): - model, res_id = model_pool.get_object_reference( cr, uid, "project", vals.get('alias_model','model_project_task')) + model_ids = model_pool.search(cr, uid, [('model', '=', vals.get('alias_model','project.task'))]) alias_id = self.browse(cr, uid, ids[0], context).alias_id - alias_pool.write(cr, uid, [alias_id.id], {'alias_model_id': res_id}, context=context) + alias_pool.write(cr, uid, [alias_id.id], {'alias_model_id': model_ids[0]}, context=context) return super(project, self).write(cr, uid, ids, vals, context=context) - class task(base_stage, osv.osv): _name = "project.task" _description = "Task" diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index 889cc285af3..fb394d1bfca 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -66,7 +66,7 @@ ref('base.user_vad')])]" name="members"/> Integrate a Sale and Warehouse Management. - model_project_task + project.task @@ -291,7 +291,7 @@ - model_project_task + project.task 10 @@ -300,7 +300,7 @@ - model_project_task + project.task 20 @@ -309,7 +309,7 @@ - model_project_task + project.task 30 @@ -317,7 +317,7 @@ Install, data import, configuration - model_project_task + project.task diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 8024e4e8c63..cc64f528cda 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -56,7 +56,7 @@ - + diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index a7322959e70..0d59315c43a 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -582,7 +582,7 @@ class project(osv.osv): _inherit = "project.project" def _get_alias_model(self, cr, uid, context=None): - return [('model_project_task', "Tasks"),("model_project_issue", "Issue")] + return [('project.task', "Tasks"),("project.issue", "Issue")] def _issue_count(self, cr, uid, ids, field_name, arg, context=None): res = dict.fromkeys(ids, 0) @@ -595,7 +595,8 @@ class project(osv.osv): 'project_escalation_id' : fields.many2one('project.project','Project Escalation', help='If any issue is escalated from the current Project, it will be listed under the project selected here.', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'reply_to' : fields.char('Reply-To Email Address', size=256), 'issue_count': fields.function(_issue_count, type='integer'), - 'alias_model': fields.selection(_get_alias_model, "Alias Model"), + 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1", required=True, + help="Allows to select Model for the Mail alias .Based on selected model Task/issue will created for fetched mails or it will maintain communication for related Task/Issue."), } def _check_escalation(self, cr, uid, ids, context=None): @@ -608,6 +609,7 @@ class project(osv.osv): _constraints = [ (_check_escalation, 'Error! You cannot assign escalation to the same project!', ['project_escalation_id']) ] + project() class account_analytic_account(osv.osv): diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 016c3f8d9d0..0738f9fe850 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -352,6 +352,9 @@ + + +