[MERGE/IMP] lp:~openerp-dev/openobject-addons/trunk-mail-alias-jam-improvement-tpa + demo record values
bzr revid: jam@tinyerp.com-20120704110617-6iz617pge7gg5x33
This commit is contained in:
commit
d823b7a881
|
@ -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 """
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -451,7 +451,7 @@
|
|||
</record>
|
||||
|
||||
<record id="mail_alias_jobs" model="mail.alias">
|
||||
<field name="alias_name">Jobs</field>
|
||||
<field name="alias_name">jobs</field>
|
||||
<field name="alias_model_id" ref="model_hr_applicant"/>
|
||||
<field name="alias_user_id" ref="base.user_root"/>
|
||||
<field name="alias_defaults">{}</field>
|
||||
|
|
|
@ -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: '{}'
|
||||
|
|
|
@ -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]})
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
ref('base.user_vad')])]" name="members"/>
|
||||
<field name="user_id" ref="base.user_al"/>
|
||||
<field name="name">Integrate a Sale and Warehouse Management.</field>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
|
||||
<!-- Tasks -->
|
||||
|
@ -291,7 +291,7 @@
|
|||
<field name="parent_id" ref="all_projects_account"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development'),ref('project_tt_testing'),ref('project_tt_merge')])]" name="type_ids"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
<record id="project_project_21" model="project.project">
|
||||
<field name="priority">10</field>
|
||||
|
@ -300,7 +300,7 @@
|
|||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development')])]" name="type_ids"/>
|
||||
<field eval="[(6, 0, [ref('base.user_root'),ref('base.user_demo')])]" name="members"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
<record id="project_project_22" model="project.project">
|
||||
<field name="priority">20</field>
|
||||
|
@ -309,7 +309,7 @@
|
|||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'), ref('project_tt_development')])]" name="type_ids"/>
|
||||
<field eval="[(6, 0, [ref('base.user_root'),ref('base.user_demo')])]" name="members"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
<record id="project_project_23" model="project.project">
|
||||
<field name="priority">30</field>
|
||||
|
@ -317,7 +317,7 @@
|
|||
<field name="name">Install, data import, configuration</field>
|
||||
<field eval="[(6, 0, [ref('project_tt_development')])]" name="type_ids"/>
|
||||
<field eval="[(6, 0, [ref('base.user_root'),ref('base.user_demo')])]" name="members"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
|
||||
<!-- Tasks -->
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<field name="parent_id" invisible="1" string="Parent" domain="[('id','!=',analytic_account_id)]" context="{'current_model': 'project.project'}"/>
|
||||
<field name="privacy_visibility"/>
|
||||
<field name="alias_id" required="0" domain="[('alias_model_id','in',('project.task','project.issue'))]"/>
|
||||
<field name="alias_model"/>
|
||||
<field name="alias_model" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<table>
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -352,6 +352,9 @@
|
|||
<field name="project_escalation_id"/>
|
||||
<field name="reply_to"/>
|
||||
</field>
|
||||
<field name="alias_model" position="replace">
|
||||
<field name="alias_model"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
Loading…
Reference in New Issue