[MERGE] mail.alias: updated views and simplified models
bzr revid: odo@openerp.com-20120705135626-xxqch4uabq418ekf
This commit is contained in:
commit
9caafbe777
|
@ -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="restrict", 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):
|
||||
|
@ -158,33 +160,19 @@ class crm_case_section(osv.osv):
|
|||
name = record['parent_id'][1] + ' / ' + name
|
||||
res.append((record['id'], name))
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(crm_case_section,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form':
|
||||
domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
if not domain:
|
||||
doc = etree.XML(res['arch'])
|
||||
alias_node = doc.xpath("//field[@name='alias_id']")[0]
|
||||
parent = alias_node.getparent()
|
||||
parent.remove(alias_node)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
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)
|
||||
|
||||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "sales_team_"+name,
|
||||
'alias_model_id': self._name}, 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(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 """
|
||||
|
|
|
@ -71,8 +71,8 @@
|
|||
<field name="name" colspan="2"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="code"/>
|
||||
<field name="alias_id" required="0" domain="[('alias_model_id', '=','crm.lead')]"/>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<field name="user_id"/>
|
||||
<field name="resource_calendar_id"/>
|
||||
|
@ -90,6 +90,12 @@
|
|||
<field name="allow_unlink"/>
|
||||
</group>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('alias_domain', '=', False)]}">
|
||||
<div name="alias_box">
|
||||
<label for="alias_name"/>
|
||||
<field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline"/>
|
||||
</div>
|
||||
</group>
|
||||
<separator string="Team Members"/>
|
||||
<field name="member_ids"/>
|
||||
</page>
|
||||
|
|
|
@ -71,7 +71,7 @@ class fetchmail_server(osv.osv):
|
|||
'password' : fields.char('Password', size=1024, readonly=True, states={'draft':[('readonly', False)]}),
|
||||
'action_id':fields.many2one('ir.actions.server', 'Server Action', help="Optional custom server action to trigger for each incoming mail, "
|
||||
"on the record that was created or updated by this mail"),
|
||||
'object_id': fields.many2one('ir.model', "Create a New Record", required=True, help="Process each incoming mail as part of a conversation "
|
||||
'object_id': fields.many2one('ir.model', "Create a New Record", help="Process each incoming mail as part of a conversation "
|
||||
"corresponding to this document type. This will create "
|
||||
"new documents for new conversations, or attach follow-up "
|
||||
"emails to the existing conversations (documents)."),
|
||||
|
@ -189,10 +189,14 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS
|
|||
result, data = imap_server.search(None, '(UNSEEN)')
|
||||
for num in data[0].split():
|
||||
result, data = imap_server.fetch(num, '(RFC822)')
|
||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model, data[0][1],
|
||||
save_original=server.original,
|
||||
strip_attachments=(not server.attach),
|
||||
context=context)
|
||||
if server.object_id:
|
||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
||||
data[0][1],
|
||||
save_original=server.original,
|
||||
strip_attachments=(not server.attach),
|
||||
context=context)
|
||||
else:
|
||||
res_id = mail_thread.message_catchall(cr, uid, data[0][1])
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
|
||||
imap_server.store(num, '+FLAGS', '\\Seen')
|
||||
|
@ -213,11 +217,14 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS
|
|||
for num in range(1, numMsgs + 1):
|
||||
(header, msges, octets) = pop_server.retr(num)
|
||||
msg = '\n'.join(msges)
|
||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
||||
msg,
|
||||
save_original=server.original,
|
||||
strip_attachments=(not server.attach),
|
||||
context=context)
|
||||
if server.object_id:
|
||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
||||
msg,
|
||||
save_original=server.original,
|
||||
strip_attachments=(not server.attach),
|
||||
context=context)
|
||||
else:
|
||||
res_id = mail_thread.message_catchall(cr, uid, data[0][1])
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
|
||||
pop_server.dele(num)
|
||||
|
|
|
@ -545,33 +545,23 @@ 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="restrict", 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):
|
||||
res = super(hr_job,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form':
|
||||
domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
if not domain:
|
||||
doc = etree.XML(res['arch'])
|
||||
alias_node = doc.xpath("//field[@name='alias_id']")[0]
|
||||
parent = alias_node.getparent()
|
||||
parent.remove(alias_node)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
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'):
|
||||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "job_"+name,
|
||||
'alias_model_id': self._name}, 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( 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: '{}'
|
||||
|
|
|
@ -382,7 +382,9 @@
|
|||
</div>
|
||||
</field>
|
||||
<field name="company_id" version="7.0" position="after">
|
||||
<field name="alias_id" required="0" domain="[('alias_model_id','=','hr.applicant')]"/>
|
||||
<div colspan="4" attrs="{'invisible': [('alias_domain', '=', False)]}">
|
||||
<field name="alias_name" nolabel="1" class="oe_inline"/>@<field name="alias_domain" nolabel="1" class="oe_inline"/>
|
||||
</div>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import re
|
||||
from openerp.osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class mail_alias(osv.Model):
|
||||
"""A Mail Alias is a mapping of an email address with a given OpenERP Document
|
||||
model. It is used by OpenERP's mail gateway when processing incoming emails
|
||||
|
@ -39,6 +41,14 @@ class mail_alias(osv.Model):
|
|||
_description = "Mail Alias"
|
||||
_rec_name = 'alias_name'
|
||||
|
||||
def _get_alias_domain(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
config_parameter_pool = self.pool.get("ir.config_parameter")
|
||||
domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
for alias in self.browse(cr, uid, ids, context=context):
|
||||
res[alias.id] = domain or ""
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'alias_name': fields.char('Mailbox Alias', size=255, required=True,
|
||||
help="The name of the mailbox alias, e.g. 'jobs' "
|
||||
|
@ -63,7 +73,8 @@ class mail_alias(osv.Model):
|
|||
'alias_force_thread_id': fields.integer('Record Thread ID',
|
||||
help="Optional ID of the thread (record) to which all "
|
||||
"messages will be attached, even if they did not reply to it. "
|
||||
"If set, this will disable the creation of new records completely.")
|
||||
"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': '{}',
|
||||
|
@ -82,9 +93,9 @@ class mail_alias(osv.Model):
|
|||
for record in self.browse(cr, uid, ids, context=context):
|
||||
try:
|
||||
dict(eval(record.alias_defaults))
|
||||
return True
|
||||
except:
|
||||
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']),
|
||||
|
@ -96,25 +107,43 @@ class mail_alias(osv.Model):
|
|||
Email Alias Domain from config.
|
||||
e.g. `jobs@openerp.my.openerp.com` or `sales@openerp.my.openerp.com`
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
res = []
|
||||
config_parameter_pool = self.pool.get("ir.config_parameter")
|
||||
domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
for record in self.read(cr, uid, ids, ['alias_name'], context=context):
|
||||
domain_alias = "%s@%s"%(record['alias_name'], domain)
|
||||
for record in self.read(cr, uid, ids, ['alias_name', 'alias_domain'], context=context):
|
||||
domain_alias = "%s@%s"%(record['alias_name'], record['alias_domain'])
|
||||
res.append((record['id'], domain_alias))
|
||||
return res
|
||||
|
||||
def create_unique_alias(self, cr, uid, values, sequence=1 ,context=None):
|
||||
if sequence:
|
||||
prob_alias = "%s%s"%(values['alias_name'], sequence)
|
||||
search_alias = self.search(cr, uid, [('alias_name', '=', prob_alias)])
|
||||
if search_alias:
|
||||
values = self.create_unique_alias(cr, uid, values, sequence+1, context)
|
||||
else:
|
||||
values.update({'alias_name': prob_alias})
|
||||
return values
|
||||
def _generate_alias(self, cr, uid, name, sequence=1 ,context=None):
|
||||
"""
|
||||
If alias is existing then this method will create a new unique alias name
|
||||
by appending n sequence integer number.
|
||||
"""
|
||||
new_name = "%s%s"%(name, sequence)
|
||||
search_alias = self.search(cr, uid, [('alias_name', '=', new_name)])
|
||||
if search_alias:
|
||||
new_name = self._generate_alias(cr, uid, name, sequence+1 ,context=None)
|
||||
if not self.search(cr, uid, [('alias_name', '=', new_name)]):
|
||||
return new_name
|
||||
else:
|
||||
return values.update({'alias_name': "%s"%(values['alias_name'])})
|
||||
return new_name
|
||||
|
||||
def create_unique_alias(self, cr, uid, vals, context=None):
|
||||
"""
|
||||
Methods accepts the vals param in dict format and create new alias record
|
||||
@vals : dict accept {alias_name: '', alias_model_id: '',...}
|
||||
@return int: New alias_id
|
||||
"""
|
||||
model_pool = self.pool.get('ir.model')
|
||||
alias_name = re.sub(r'\W+', '_', vals['alias_name']).lower()
|
||||
values = {'alias_name': alias_name}
|
||||
#Find for the mail alias exist or not if exit then get new mail address.
|
||||
saids = self.search(cr, uid, [('alias_name', '=',alias_name)])
|
||||
if saids:
|
||||
alias_name = self._generate_alias(cr, uid, alias_name, sequence=1, context=context)
|
||||
values.update({'alias_name': alias_name})
|
||||
#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]})
|
||||
return self.create(cr, uid, values, context=context)
|
||||
|
||||
|
||||
|
|
|
@ -11,12 +11,15 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Alias" version="7.0">
|
||||
<sheet>
|
||||
<label for="alias_name" class="oe_edit_only"/>
|
||||
<h2><field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline"/></h2>
|
||||
<group colspan="4" col="4">
|
||||
<field name="alias_name"/>
|
||||
<field name="alias_model_id" readonly="1"/>
|
||||
<field name="alias_user_id"/>
|
||||
<field name="alias_force_thread_id"/>
|
||||
<field name="alias_defaults"/>
|
||||
<field name="alias_user_id" readonly="1"/>
|
||||
<field name="alias_force_thread_id" readonly="1"/>
|
||||
<newline/>
|
||||
<separator string="Alias Mailbox Default Values" colspan="4"/>
|
||||
<field name="alias_defaults" colspan="4" nolabel="1" readonly="1"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
|
@ -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="restrict", 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 = {
|
||||
|
@ -139,26 +141,16 @@ class mail_group(osv.osv):
|
|||
'photo': _get_default_photo,
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(mail_group,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form':
|
||||
domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
if not domain:
|
||||
doc = etree.XML(res['arch'])
|
||||
alias_node = doc.xpath("//field[@name='alias_id']")[0]
|
||||
parent = alias_node.getparent()
|
||||
parent.remove(alias_node)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
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')
|
||||
model, res_id = model_pool.get_object_reference( cr, uid, "mail", "model_mail_group")
|
||||
vals.update({'alias_name': "mailing-group",
|
||||
'alias_model_id': res_id})
|
||||
alias_pool.create_unique_alias(cr, uid, vals, context=context)
|
||||
res = super( mail_group, self).create(cr, uid, vals, context)
|
||||
record = self.read(cr, uid, res, context)
|
||||
alias_pool.write(cr, uid, [record['alias_id']], {"alias_force_thread_id":record['id']}, context)
|
||||
if not vals.get('alias_id'):
|
||||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "mail_group_"+name,
|
||||
'alias_model_id': self._name}, 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(mail_group, self).create(cr, uid, vals, context)
|
||||
alias_pool.write(cr, uid, [vals['alias_id']], {"alias_force_thread_id": res}, context)
|
||||
return res
|
||||
|
||||
|
|
|
@ -60,13 +60,15 @@
|
|||
<div class="oe_edit_only">
|
||||
<label for="name"/>
|
||||
</div>
|
||||
<h2><field name="name" colspan="4"/></h2>
|
||||
<div>
|
||||
<h2><field name="name" colspan="4"/></h2>
|
||||
<div name="alias_box" colspan="4" attrs="{'invisible': [('alias_domain', '=', False)]}" class="oe_edit_only">
|
||||
<field name="alias_name" nolabel="1" class="oe_inline"/>@<field name="alias_domain" nolabel="1" class="oe_inline"/>
|
||||
</div>
|
||||
</div>
|
||||
<newline/>
|
||||
<group colspan="4" col="4">
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
<div class="oe_edit_only">
|
||||
<field name="alias_id" required="0" domain="[('alias_model_id','=','mail.group')]" />
|
||||
</div>
|
||||
</group>
|
||||
<group colspan="2" col="2" class="oe_edit_only">
|
||||
<field name="responsible_id" colspan="2"/>
|
||||
|
|
|
@ -25,7 +25,7 @@ class project_configuration(osv.TransientModel):
|
|||
_inherit = 'base.config.settings'
|
||||
|
||||
_columns = {
|
||||
'alias_domain' : fields.char('Catch-all Mail Alias Domain', size=None,
|
||||
'alias_domain' : fields.char('Alias Domain', size=None,
|
||||
help="If you have setup a catch-all mail domain redirected to "
|
||||
"the OpenERP server, enter the domain name here."),
|
||||
}
|
||||
|
|
|
@ -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', 'Alias', ondelete="restrict", 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 = {
|
||||
|
@ -58,28 +60,14 @@ class res_users(osv.osv):
|
|||
self.SELF_WRITEABLE_FIELDS.append('notification_email_pref')
|
||||
return init_res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(res_users,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form':
|
||||
domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
if not domain:
|
||||
doc = etree.XML(res['arch'])
|
||||
alias_node = doc.xpath("//field[@name='alias_id']")[0]
|
||||
parent = alias_node.getparent()
|
||||
parent.remove(alias_node)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def create(self, cr, uid, data, context=None):
|
||||
# create default alias same as the login
|
||||
model_pool = self.pool.get('ir.model.data')
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
res_id = model_pool.get_object( cr, uid, "mail", "model_res_users")
|
||||
data.update({'alias_name': data.get('login'),
|
||||
'alias_model_id': res_id.id})
|
||||
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)
|
||||
user = self.browse(cr, uid, user_id, context=context)
|
||||
alias_pool.write(cr, uid, [user.alias_id.id], {"alias_force_thread_id": user.id}, context)
|
||||
# make user follow itself
|
||||
self.message_subscribe(cr, uid, [user_id], [user_id], context=context)
|
||||
# create a welcome message to broadcast
|
||||
|
@ -91,7 +79,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)
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
</div>
|
||||
</xpath>
|
||||
<field name="active" position="after">
|
||||
<field name="alias_id" readonly="1" required="0"/>
|
||||
<group colspan="2" attrs="{'invisible': [('alias_domain', '=', False)]}">
|
||||
<field name="alias_id" readonly="1"/><field name="alias_domain" invisible="1"/>
|
||||
</group>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
|
|
|
@ -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="restrict", 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 ?
|
||||
|
@ -254,26 +257,6 @@ class project(osv.osv):
|
|||
(_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date'])
|
||||
]
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(project,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||
if view_type == 'form' or view_type == 'kanban':
|
||||
domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
if not domain:
|
||||
doc = etree.XML(res['arch'])
|
||||
alias_node = doc.xpath("//field[@name='alias_id']")[0]
|
||||
parent = alias_node.getparent()
|
||||
parent.remove(alias_node)
|
||||
if view_type == "form":
|
||||
model_node = doc.xpath("//field[@name='alias_model']")[0]
|
||||
parent = model_node.getparent()
|
||||
parent.remove(model_node)
|
||||
else:
|
||||
model_node = doc.xpath("//field[@name='alias_id']")[0]
|
||||
parent = model_node.getparent()
|
||||
parent.remove(model_node)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def set_template(self, cr, uid, ids, context=None):
|
||||
res = self.setActive(cr, uid, ids, value=False, context=context)
|
||||
return res
|
||||
|
@ -330,10 +313,11 @@ class project(osv.osv):
|
|||
context['active_test'] = False
|
||||
default['state'] = 'open'
|
||||
default['tasks'] = []
|
||||
default['alias_id'] = False
|
||||
proj = self.browse(cr, uid, id, context=context)
|
||||
if not default.get('name', False):
|
||||
default['name'] = proj.name + _(' (copy)')
|
||||
|
||||
default['alias_name'] = default['name']
|
||||
res = super(project, self).copy(cr, uid, id, default, context)
|
||||
self.map_tasks(cr,uid,id,res,context)
|
||||
return res
|
||||
|
@ -514,15 +498,16 @@ def Project():
|
|||
return user_ids
|
||||
|
||||
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'):
|
||||
name = vals.get('alias_name') or vals['name']
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid,
|
||||
{'alias_name': "project_"+name,
|
||||
'alias_model_id': self._name}, 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)
|
||||
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
|
||||
|
||||
|
@ -546,16 +531,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 -->
|
||||
|
|
|
@ -93,8 +93,6 @@
|
|||
<field name="analytic_account_id" invisible="1" required="0"/>
|
||||
<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"/>
|
||||
</group>
|
||||
<group>
|
||||
<table>
|
||||
|
@ -142,6 +140,14 @@
|
|||
<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">
|
||||
|
@ -238,6 +244,7 @@
|
|||
<field name="color"/>
|
||||
<field name="task_count"/>
|
||||
<field name="alias_id"/>
|
||||
<field name="alias_domain"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_project oe_kanban_auto_height oe_kanban_global_click">
|
||||
|
@ -262,14 +269,13 @@
|
|||
<div>Deadline</div>
|
||||
<div><field name="date"/></div>
|
||||
</div>
|
||||
<div t-if="record.alias_id.raw_value">
|
||||
<a t-attf-href="mailto:#{record.alias_id.raw_value}"><field name="alias_id"/></a>
|
||||
</div>
|
||||
<div class="oe_kanban_project_fields oe_kanban_project_progress">
|
||||
<div>Progress</div>
|
||||
<div><t t-esc="Math.round(record.effective_hours.raw_value)"/> / <t t-esc="Math.round(record.planned_hours.raw_value)"/> <field name="company_uom_id"/></div>
|
||||
</div>
|
||||
|
||||
<div name="alias_box" t-if="record.alias_domain.raw_value" class="oe_kanban_ellipsis">
|
||||
<a t-attf-href="mailto:#{record.alias_id.value}"><field name="alias_id"/></a>
|
||||
</div>
|
||||
<div class="oe_kanban_project_avatars">
|
||||
<t t-foreach="record.members.raw_value" t-as="member">
|
||||
<img t-att-src="kanban_image('res.users', 'avatar', member)" t-att-data-member_id="member"/>
|
||||
|
|
|
@ -563,7 +563,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)
|
||||
|
@ -576,7 +576,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):
|
||||
|
@ -589,6 +590,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):
|
||||
|
|
|
@ -394,6 +394,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