diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 1749a4a29cb..d2fd549ff5e 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -122,9 +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, - 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."), + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, + help="The email address associated with this team. New emails received will automatically " + "create new leads assigned to the team."), } def _get_stage_common(self, cr, uid, context): diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv index 7707118324f..358720356ab 100644 --- a/addons/crm/security/ir.model.access.csv +++ b/addons/crm/security/ir.model.access.csv @@ -19,7 +19,7 @@ access_crm_phonecall,crm.phonecall,model_crm_phonecall,base.group_sale_salesman, access_crm_phonecall_all,crm.phonecall.all,model_crm_phonecall,base.group_user,1,0,0,0 access_crm_case_section_user,crm.case.section.user,model_crm_case_section,base.group_sale_salesman,1,1,1,0 access_crm_case_section_manager,crm.case.section.manager,model_crm_case_section,base.group_sale_manager,1,1,1,1 -access_crm_case_stage,crm.case.stage,model_crm_case_stage,base.group_user,1,0,0,0 +access_crm_case_stage,crm.case.stage,model_crm_case_stage,,1,0,0,0 access_crm_case_stage_manager,crm.case.stage,model_crm_case_stage,base.group_sale_manager,1,1,1,1 access_crm_case_resource_type_user,crm_case_resource_type user,model_crm_case_resource_type,base.group_sale_salesman,1,1,1,0 access_crm_case_resource_type_manager,crm_case_resource_type manager,model_crm_case_resource_type,base.group_sale_manager,1,1,1,1 diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 2ce581eb5e6..efe7db28dc8 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -545,9 +545,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, - 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."), + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, + help="The email address associated with this job position. New emails received will automatically " + "create new applicants for this job."), } def create(self, cr, uid, vals, context=None): diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 4ca22132b4a..2108fc0ae46 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -76,10 +76,12 @@ class mail_alias(osv.Model): "If set, this will disable the creation of new records completely."), 'alias_domain': fields.function(_get_alias_domain, string="Alias Doamin", type='char', size=None), } + _defaults = { 'alias_defaults': '{}', 'alias_user_id': lambda self,cr,uid, context: uid } + _sql_constraints = [ ('mailbox_uniq', 'UNIQUE(alias_name)', 'Unfortunately this mail alias is already used, please choose a unique one') ] @@ -93,12 +95,12 @@ class mail_alias(osv.Model): for record in self.browse(cr, uid, ids, context=context): try: dict(eval(record.alias_defaults)) - except: + except Exception: return False return True _constraints = [ - (_check_alias_defaults, "Default Values are in wrong format.\nIt must be in python dictionary format e.g.{'field_name': 'value' or {}}", ['alias_defaults']), + (_check_alias_defaults, '''Invalid expression, it must be a literal python dictionary definition e.g. "{'field': 'value'}"''', ['alias_defaults']), ] def name_get(self, cr, uid, ids, context=None): diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index e31ae678f5d..6e949217269 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -130,9 +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, - 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.") + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, + help="The email address associated with this group. New emails received will automatically " + "create new topics."), } _defaults = { diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 4ff2901f45d..5643a6fde5b 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -41,8 +41,8 @@ class res_users(osv.osv): ], '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', '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."), + help="The email address associated with this user. New emails received will automatically " + "appear in the user's notifications."), } _defaults = { diff --git a/addons/project/project.py b/addons/project/project.py index 631dc352700..56718a92790 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -171,7 +171,9 @@ class project(osv.osv): for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): res[task.project_id.id] += 1 return res - def _get_alias_model(self, cr, uid, context=None): + + def _get_alias_models(self, cr, uid, context=None): + """Overriden in project_issue to offer more options""" return [('project.task', "Tasks")] def _get_followers(self, cr, uid, ids, name, arg, context=None): @@ -191,6 +193,9 @@ class project(osv.osv): project_ids = project_obj.search(cr, uid, [('message_ids.user_id.id', 'in', args[0][2])], context=context) return [('id', 'in', project_ids)] + # Lambda indirection method to avoid passing a copy of the overridable method when declaring the field + _alias_models = lambda self, *args, **kwargs: self._get_alias_models(*args, **kwargs) + _columns = { 'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250), 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the project without removing it."), @@ -224,11 +229,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, - 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."), + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, + help="The email address associated with this project. New emails received will automatically " + "create project tasks (optionally project issues if the Project Issue module is installed)."), + 'alias_model': fields.selection(_alias_models, "Alias Model", select=True, required=True, + help="The kind of document created when an email is received by this project's email alias"), '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, @@ -249,7 +254,7 @@ class project(osv.osv): 'priority': 1, 'sequence': 10, 'type_ids': _get_type_common, - 'alias_model':'project.task', + 'alias_model': 'project.task', } # TODO: Why not using a SQL contraints ? @@ -510,7 +515,7 @@ def Project(): name = vals.get('alias_name') or vals['name'] alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': "project_"+name, - 'alias_model_id': vals.get('alias_model', 'project.task')}, context=context) + 'alias_model_id': vals.get('alias_model', 'project.task')}, context=context) alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context) vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']}) res = super( project, self).create(cr, uid, vals, context) @@ -539,12 +544,10 @@ def Project(): def write(self, cr, uid, ids, vals, context=None): 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 alias_model has been changed, update alias_model_id of alias accordingly if vals.get('alias_model'): 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': model_ids[0]}, context=context) + vals.update(alias_model_id=model_ids[0]) return super(project, self).write(cr, uid, ids, vals, context=context) class task(base_stage, osv.osv): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 5af82ff526c..6f8c83ac4c1 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -82,6 +82,11 @@

+
+