[IMP] mail alias review - work in progress

bzr revid: odo@openerp.com-20120801091439-2m7z9fhn771go35j
This commit is contained in:
Olivier Dony 2012-08-01 11:14:39 +02:00
parent 8819d7ba3d
commit 093f739273
10 changed files with 40 additions and 40 deletions

View File

@ -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):

View File

@ -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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
19 access_crm_phonecall_all crm.phonecall.all model_crm_phonecall base.group_user 1 0 0 0
20 access_crm_case_section_user crm.case.section.user model_crm_case_section base.group_sale_salesman 1 1 1 0
21 access_crm_case_section_manager crm.case.section.manager model_crm_case_section base.group_sale_manager 1 1 1 1
22 access_crm_case_stage crm.case.stage model_crm_case_stage base.group_user 1 0 0 0
23 access_crm_case_stage_manager crm.case.stage model_crm_case_stage base.group_sale_manager 1 1 1 1
24 access_crm_case_resource_type_user crm_case_resource_type user model_crm_case_resource_type base.group_sale_salesman 1 1 1 0
25 access_crm_case_resource_type_manager crm_case_resource_type manager model_crm_case_resource_type base.group_sale_manager 1 1 1 1

View File

@ -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):

View File

@ -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):

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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):

View File

@ -82,6 +82,11 @@
<h1>
<field name="name" string="Project Name"/>
</h1>
<div attrs="{'invisible': [('alias_domain', '=', False)]}">
<label for="alias_name" class="oe_edit_only"/>
<field name="alias_name" required="0" class="oe_inline"/>@<field name="alias_domain" class="oe_inline"/>
<field name="alias_model" invisible="1" class="oe_inline oe_edit_only"/>
</div>
<label for="parent_id" class="oe_edit_only" string="Parent Project"/>
<h2>
<field name="parent_id" domain="[('id','!=',analytic_account_id)]" context="{'current_model': 'project.project'}"/>
@ -140,14 +145,6 @@
<field name="active" attrs="{'invisible':[('state','in',['open', 'pending', 'template'])]}"/>
<field name="currency_id" groups="base.group_multi_company" required="1"/>
</group>
<group string="Mailbox Alias" colspan="4" attrs="{'invisible': [('alias_domain', '=', False)]}">
<div>
<label for="alias_name"/>
<field name="alias_name" required="0" class="oe_inline"/>@
<field name="alias_domain" class="oe_inline"/>
</div>
<field name="alias_model" invisible="1"/>
</group>
</group>
</page>
<page string="Tasks Stages">

View File

@ -562,8 +562,8 @@ project_issue()
class project(osv.osv):
_inherit = "project.project"
def _get_alias_model(self, cr, uid, context=None):
return [('project.task', "Tasks"),("project.issue", "Issue")]
def _get_alias_models(self, cr, uid, context=None):
return [('project.task', "Tasks"), ("project.issue", "Issue")]
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0)
@ -576,8 +576,6 @@ 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",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):

View File

@ -394,8 +394,8 @@
<field name="project_escalation_id"/>
<field name="reply_to"/>
</field>
<field name="alias_model" position="replace">
<field name="alias_model"/>
<field name="alias_model" position="attributes">
<attribute name="invisible" value="0"/>
</field>
</field>
</record>