[IMP] mail alias review - work in progress

bzr revid: odo@openerp.com-20120806004417-9uviymtavkxlh92m
This commit is contained in:
Olivier Dony 2012-08-06 02:44:17 +02:00
parent f0873dcb32
commit 56009ed513
20 changed files with 158 additions and 194 deletions

View File

@ -166,10 +166,10 @@ class crm_case_section(osv.osv):
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': "sales_team_"+name,
'alias_model_id': "crm.lead"}, context=context)
alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context)
vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']})
{'alias_name': name},
model_name="crm.lead",
context=context)
vals['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

View File

@ -54,8 +54,8 @@ class base_action_rule(osv.osv):
name = '[%d] %s' % (obj.id, tools.ustr(obj.name))
emailfrom = tools.ustr(emailfrom)
if hasattr(obj, 'section_id') and obj.section_id and obj.section_id.reply_to:
reply_to = obj.section_id.reply_to
if hasattr(obj, 'section_id') and obj.section_id and obj.section_id.alias_id:
reply_to = obj.section_id.alias_id.name_get()[0][1]
else:
reply_to = emailfrom
if not emailfrom:

View File

@ -87,20 +87,13 @@
</group>
<notebook colspan="4">
<page string="Sales Team">
<group col="4">
<group>
<field name="reply_to"/>
</group>
<group>
<field name="change_responsible"/>
<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>
<div name="alias_box" attrs="{'invisible': [('alias_domain', '=', False)]}">
<label for="alias_name"/>
<field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline"/>
</div>
<group>
<field name="change_responsible"/>
<field name="allow_unlink"/>
</group>
<separator string="Team Members"/>
<field name="member_ids"/>

View File

@ -520,10 +520,10 @@ class hr_job(osv.osv):
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': "hr.applicant"}, context=context)
alias = alias_pool.read(cr, uid, alias_id, ['alias_name'],context)
vals.update({'alias_id': alias_id, 'alias_name': alias['alias_name']})
{'alias_name': "job_"+name},
model_name="hr.applicant",
context=context)
vals['alias_id'] = alias_id
res = super( hr_job, self).create(cr, uid, vals, context)
alias_pool.write(cr, uid, [vals['alias_id']], {"alias_defaults": {'job_id': res}}, context)
return res

View File

@ -64,17 +64,16 @@ The main features of the module are:
'wizard/mail_compose_message_view.xml',
'res_config_view.xml',
'mail_message_view.xml',
'mail_alias_data.xml',
'mail_subscription_view.xml',
'mail_thread_view.xml',
'mail_group_view.xml',
'res_partner_view.xml',
'res_users_view.xml',
'data/mail_data.xml',
'data/mail_group_data.xml',
'security/mail_security.xml',
'security/ir.model.access.csv',
'mail_alias_view.xml',
'res_users_view.xml',
],
'demo': [
'data/mail_demo.xml',

View File

@ -12,18 +12,5 @@
<field eval="'process_email_queue'" name="function"/>
<field eval="'()'" name="args"/>
</record>
<record id="mail_alias_root_user" model="mail.alias">
<field name="alias_name">admin</field>
<field name="alias_model_id" ref="model_res_users"/>
<field name="alias_user_id" ref="base.user_root"/>
<field name="alias_force_thread_id" ref="base.user_root"/>
<field name="alias_defaults">{}</field>
</record>
<record model="res.users" id="base.user_root">
<field name="alias_id" ref="mail_alias_root_user"/>
</record>
</data>
</openerp>

View File

@ -88,20 +88,10 @@ Check the file in attachment for more information ! (third comment)]]></field>
<field name="attachment_ids" eval="[(4,ref('message_blogpost0_comment2_attachment0'))]"/>
</record>
<record model="ir.config_parameter" id="user_mail_alias">
<field name="key">mail.catchall.domain</field>
<field name="value">demo.openerp.com</field>
</record>
</data>
<data noupdate="1">
<record id="mail_alias_demo_user" model="mail.alias">
<field name="alias_name">demo</field>
<field name="alias_model_id" ref="model_res_users"/>
<field name="alias_user_id" ref="base.user_root"/>
<field name="alias_force_thread_id" ref="base.user_demo"/>
<field name="alias_defaults">{}</field>
</record>
<record model="res.users" id="base.user_demo">
<field name="alias_id" ref="mail_alias_demo_user"/>
</record>
</data>
</openerp>

View File

@ -20,8 +20,8 @@
##############################################################################
import re
from openerp.osv import fields, osv
from tools.translate import _
class mail_alias(osv.Model):
@ -38,20 +38,17 @@ class mail_alias(osv.Model):
created, it becomes immediately usable and OpenERP will accept email for it.
"""
_name = 'mail.alias'
_description = "Mail Alias"
_description = "Email Aliases"
_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
ir_config_parameter = self.pool.get("ir.config_parameter")
domain = ir_config_parameter.get_param(cr, uid, "mail.catchall.domain", context=context)
return dict.fromkeys(ids, domain or "")
_columns = {
'alias_name': fields.char('Mailbox Alias', size=255, required=True,
help="The name of the mailbox alias, e.g. 'jobs' "
'alias_name': fields.char('Alias', required=True,
help="The name of the email alias, e.g. 'jobs' "
"if you want to catch emails for <jobs@example.my.openerp.com>",),
'alias_model_id': fields.many2one('ir.model', 'Aliased Model', required=True,
help="The model (OpenERP Document Kind) to which this alias "
@ -64,17 +61,17 @@ class mail_alias(osv.Model):
),
'alias_user_id': fields.many2one('res.users', 'Owner',
help="The owner of records created upon receiving emails on this alias. "
"If this field is kept empty the system will attempt to find the right owner "
"If this field is not set the system will attempt to find the right owner "
"based on the sender (From) address, or will use the Administrator account "
"if no system user is found for that address."),
'alias_defaults': fields.text('Default Values', required=True,
help="The representation of a Python dictionary that will be evaluated to provide "
"default values when creating new records."),
help="A Python dictionary that will be evaluated to provide "
"default values when creating new records for this alias."),
'alias_force_thread_id': fields.integer('Record Thread ID',
help="Optional ID of the thread (record) to which all "
help="Optional ID of a thread (record) to which all incoming "
"messages will be attached, even if they did not reply to it. "
"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),
'alias_domain': fields.function(_get_alias_domain, string="Alias Domain", type='char', size=None),
}
_defaults = {
@ -87,16 +84,11 @@ class mail_alias(osv.Model):
]
def _check_alias_defaults(self, cr, uid, ids, context=None):
"""
Strick constraints checking for the alias defaults values.
it must follow the python dict format. So message_catachall
will not face any issue.
"""
for record in self.browse(cr, uid, ids, context=context):
try:
try:
for record in self.browse(cr, uid, ids, context=context):
dict(eval(record.alias_defaults))
except Exception:
return False
except Exception:
return False
return True
_constraints = [
@ -104,48 +96,38 @@ class mail_alias(osv.Model):
]
def name_get(self, cr, uid, ids, context=None):
"""Return the mail alias display alias_name, inclusing the implicit
mail catchall domain from config.
e.g. `jobs@openerp.my.openerp.com` or `sales@openerp.my.openerp.com`
"""
Return the mail alias display alias_name, inclusing the Implicit and dynamic
Email Alias Domain from config.
e.g. `jobs@openerp.my.openerp.com` or `sales@openerp.my.openerp.com`
"""
res = []
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
return [(record['id'], "%s@%s" % (record['alias_name'], record['alias_domain']))
for record in self.read(cr, uid, ids, ['alias_name', 'alias_domain'], context=context)]
def _generate_alias(self, cr, uid, name, sequence=1 ,context=None):
def _find_unique(self, cr, uid, name, context=None):
"""Find a unique alias name similar to ``name``. If ``name`` is
already taken, make a variant by adding an integer suffix until
an unused alias is found.
"""
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)
sequence = None
while True:
new_name = "%s%s" % (name, sequence) if sequence is not None else name
if not self.search(cr, uid, [('alias_name', '=', new_name)]):
return new_name
else:
return new_name
break
sequence = (sequence + 1) if sequence else 2
return new_name
def create_unique_alias(self, cr, uid, vals, context=None):
def create_unique_alias(self, cr, uid, vals, model_name=None, context=None):
"""Creates an email.alias record according to the values provided in ``vals``,
with 2 alterations: the ``alias_name`` value may be suffixed in order to
make it unique, and the ``alias_model_id`` value will set to the
model ID of the ``model_name`` value, if provided,
"""
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)
alias_name = self._find_unique(cr, uid, alias_name, context=context)
vals['alias_name'] = alias_name
if model_name:
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', model_name)], context=context)[0]
vals['alias_model_id'] = model_id
return self.create(cr, uid, vals, context=context)

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.config_parameter" id="user_mail_alias">
<field name="key">mail.catchall.domain</field>
<field name="value">openerp.my.openerp.com</field>
</record>
</data>
</openerp>

View File

@ -2,12 +2,11 @@
<openerp>
<data>
<!-- Alias Form View !-->
<!-- Alias Form View -->
<record model="ir.ui.view" id="view_mail_alias_form">
<field name="name">mail.alias.form</field>
<field name="model">mail.alias</field>
<field name="type">form</field>
<field name="priority" eval="10"/>
<field name="arch" type="xml">
<form string="Alias" version="7.0">
<sheet>
@ -18,7 +17,7 @@
<field name="alias_user_id" readonly="1"/>
<field name="alias_force_thread_id" readonly="1"/>
<newline/>
<separator string="Alias Mailbox Default Values" colspan="4"/>
<separator string="Default Values" colspan="4"/>
<field name="alias_defaults" colspan="4" nolabel="1" readonly="1"/>
</group>
</sheet>
@ -26,7 +25,7 @@
</field>
</record>
<!-- Alias List View !-->
<!-- Alias List View -->
<record model="ir.ui.view" id="view_mail_alias_tree">
<field name="name">mail.alias.tree</field>
<field name="model">mail.alias</field>
@ -41,7 +40,7 @@
</field>
</record>
<!-- Alias Search View !-->
<!-- Alias Search View -->
<record model="ir.ui.view" id="view_mail_alias_search">
<field name="name">mail.alias.search</field>
<field name="model">mail.alias</field>
@ -59,11 +58,8 @@
</record>
<record id="action_view_mail_alias" model="ir.actions.act_window">
<field name="name">Mail Alias</field>
<field name="name">Aliases</field>
<field name="res_model">mail.alias</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_mail_alias_search"/>
</record>
<menuitem id="mail_alias_menu"

View File

@ -167,10 +167,9 @@ class mail_group(osv.osv):
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']})
{'alias_name': "group_"+name},
model_name=self._name, context=context)
vals['alias_id'] = alias_id
mail_group_id = super(mail_group, self).create(cr, uid, vals, context)
alias_pool.write(cr, uid, [vals['alias_id']], {"alias_force_thread_id": mail_group_id}, context)

View File

@ -585,32 +585,29 @@ class mail_thread(osv.Model):
else raise Exception so that mailgate script will reject the mail and
send notification mail sender that this mailbox does not exist so your mail have been rejected.
"""
alias_pool = self.pool.get('mail.alias')
user_pool = self.pool.get('res.users')
mail_compose_pool = self.pool.get('mail.compose.message')
mail_message_pool = self.pool.get('mail.message')
mail_alias = self.pool.get('mail.alias')
mail_message = self.pool.get('mail.message')
if isinstance(message, xmlrpclib.Binary):
message = str(message.data)
if isinstance(message, unicode):
message = message.encode('utf-8')
msg_txt = email.message_from_string(message)
msg = mail_message_pool.parse_message(msg_txt)
alias_name = msg.get('to').split("@")[0]
alias_ids = alias_pool.search(cr, uid, [('alias_name','=',alias_name)])
#if alias found then call message_process method.
msg = mail_message.parse_message(msg_txt)
alias_name = msg.get('to').split("@")[0] # @@@@
alias_ids = mail_alias.search(cr, uid, [('alias_name','=',alias_name)])
#if alias found then call message_process method. # @@@@
if alias_ids:
alias_id = alias_pool.browse(cr, uid, alias_ids[0], context)
alias_id = mail_alias.browse(cr, uid, alias_ids[0], context)
user_id = self._get_user( cr, uid, alias_id, context)
alias_defaults = dict(eval(alias_id.alias_defaults or {}))
self.message_process(cr, user_id, alias_id.alias_model_id.model, message,
custom_values = alias_defaults,
thread_id = alias_id.alias_force_thread_id or False,
custom_values=alias_defaults,
thread_id=alias_id.alias_force_thread_id or False,
context=context)
else:
#if Mail box for the intended Mail Alias then give logger warning
_logger.warning("No Mail Alias Found for the name '%s'."%(alias_name))
raise
raise # @@@@
return True
#------------------------------------------------------

View File

@ -7,7 +7,7 @@
<field name="inherit_id" ref="base_setup.view_general_configuration"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/sheet/group[@string='Others']" position='inside'>
<xpath expr="//separator[@string='Others']" position='after'>
<field name="alias_domain" placeholder="mycompany.my.openerp.com"/>
</xpath>
</field>

View File

@ -19,9 +19,14 @@
#
##############################################################################
import logging
from osv import osv, fields
from openerp.modules.registry import RegistryManager
from openerp import SUPERUSER_ID
from tools.translate import _
from lxml import etree
_logger = logging.getLogger(__name__)
class res_users(osv.osv):
""" Update of res.users class
@ -43,14 +48,14 @@ class res_users(osv.osv):
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="The email address associated with this user. New emails received will automatically "
"appear in the user's notifications."),
help="Email address internally associated with this user. Incoming emails will appear "
"in the user's notifications."),
}
_defaults = {
'notification_email_pref': 'to_me',
}
def __init__(self, pool, cr):
""" Override of __init__ to add access rights on notification_email_pref
field. Access rights are disabled by default, but allowed on
@ -61,27 +66,48 @@ class res_users(osv.osv):
self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
self.SELF_WRITEABLE_FIELDS.append('notification_email_pref')
return init_res
def init(self, cr):
# Installation hook to create aliases for all users, right after _auto_init
registry = RegistryManager.get(cr.dbname)
mail_alias = registry.get('mail.alias')
res_users = registry.get('res.users')
users_no_alias = res_users.search(cr, SUPERUSER_ID, [('alias_id', '=', False)])
# User read() not browse(), to avoid prefetching uninitialized inherited fields
for user_data in res_users.read(cr, SUPERUSER_ID, users_no_alias, ['login']):
alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, {'alias_name': user_data['login'],
'alias_model_id': self._name,
'alias_force_id': user_data['id']})
res_users.write(cr, SUPERUSER_ID, user_data['id'], {'alias_id': alias_id})
_logger.info('Mail alias created for user_data %s (uid %s)', user_data['login'], user_data['id'])
# Finally attempt to reinstate the missing constraint
try:
cr.execute('ALTER TABLE res_users ALTER COLUMN alias_id SET NOT NULL')
except Exception:
pass
def create(self, cr, uid, data, context=None):
# create default alias same as the login
mail_alias = self.pool.get('mail.alias')
alias_id = mail_alias.create_unique_alias(cr, uid, {'alias_name': data['login'], 'alias_model_id': self._name}, context=context)
data.update({'alias_id': alias_id})
alias_id = mail_alias.create_unique_alias(cr, uid, {'alias_name': data['login']}, model_name=self._name, context=context)
data['alias_id'] = alias_id
user_id = super(res_users, self).create(cr, uid, data, context=context)
mail_alias.write(cr, uid, [alias_id], {"alias_force_thread_id": user_id}, context)
mail_alias.write(cr, SUPERUSER_ID, [alias_id], {"alias_force_thread_id": user_id}, context)
user = self.browse(cr, uid, user_id, context=context)
# make user follow itself
self.message_subscribe(cr, uid, [user_id], [user_id], context=context)
# create a welcome message
company_name = user.company_id.name if user.company_id else 'the company'
message = _('%s has joined %s! Welcome in OpenERP !') % (user.name, company_name)
self.message_append_note(cr, uid, [user_id], subject='Welcom to OpenERP', body=message, type='comment', context=context)
company_name = user.company_id.name if user.company_id else _('the company')
message = _('%s has joined %s! Welcome to OpenERP !') % (user.name, company_name)
self.message_append_note(cr, uid, [user_id], subject='Welcome to OpenERP', body=message, type='comment', context=context)
return user_id
def write(self, cr, uid, ids, vals, context=None):
# if login of user have been changed then change alias of user also.
if vals.get('login'):
vals['alias_name'] = vals['login']
# User alias is sync'ed with login
if vals.get('login'): vals['alias_name'] = vals['login']
return super(res_users, self).write(cr, uid, ids, vals, context=context)
def unlink(self, cr, uid, ids, context=None):

View File

@ -31,10 +31,9 @@
<field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
</div>
</xpath>
<field name="active" position="after">
<group colspan="2" attrs="{'invisible': [('alias_domain', '=', False)]}">
<field name="alias_id" readonly="1"/><field name="alias_domain" invisible="1"/>
</group>
<field name="user_email" position="after">
<field name="alias_domain" invisible="1"/>
<field name="alias_id" readonly="1" attrs="{'invisible': [('alias_domain', '=', False)]}"/>
</field>
</data>
</field>

View File

@ -52,10 +52,20 @@ class project_task_type(osv.osv):
}
_order = 'sequence'
def short_name(name):
"""Keep first word(s) of name to make it small enough
but distinctive"""
if not name: return name
# keep 7 chars + end of the last word
hardcut_tokens = name[:7].split()
return ' '.join(name.split()[:len(hardcut_tokens)])
class project(osv.osv):
_name = "project.project"
_description = "Project"
_inherits = {'account.analytic.account': "analytic_account_id","mail.alias":"alias_id"}
_inherits = {'account.analytic.account': "analytic_account_id",
"mail.alias": "alias_id"}
_inherit = ['ir.needaction_mixin', 'mail.thread']
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
@ -230,10 +240,10 @@ class project(osv.osv):
'task_count': fields.function(_task_count, type='integer', string="Open Tasks"),
'color': fields.integer('Color Index'),
'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)."),
help="Internal email associated with this project. Incoming emails are automatically synchronized"
"with Tasks (or optionally Issues if the Issue Tracker 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"),
help="The kind of document created when an email is received on this project's email alias"),
'privacy_visibility': fields.selection([('public','Public'), ('followers','Followers Only')], 'Privacy / Visibility', required=True),
'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,
@ -512,18 +522,18 @@ def Project():
return user_ids
def create(self, cr, uid, vals, context=None):
alias_pool = self.pool.get('mail.alias')
mail_alias = self.pool.get('mail.alias')
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': 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)
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
name = vals.pop('alias_name', None) or vals['name']
alias_id = mail_alias.create_unique_alias(cr, uid,
{'alias_name': "project_"+short_name(name)},
model_name=vals.get('alias_model', 'project.task'),
context=context)
vals['alias_id'] = alias_id
project_id = super(project, self).create(cr, uid, vals, context)
mail_alias.write(cr, uid, [vals['alias_id']], {'alias_defaults': {'project_id': project_id} }, context)
self.create_send_note(cr, uid, [project_id], context=context)
return project_id
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Project has been <b>created</b>."), context=context)
@ -545,10 +555,9 @@ 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')
# if alias_model has been changed, update alias_model_id of alias accordingly
# if alias_model has been changed, update alias_model_id accordingly
if vals.get('alias_model'):
model_ids = model_pool.search(cr, uid, [('model', '=', vals.get('alias_model','project.task'))])
model_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', vals.get('alias_model', 'project.task'))])
vals.update(alias_model_id=model_ids[0])
return super(project, self).write(cr, uid, ids, vals, context=context)

View File

@ -82,9 +82,7 @@
<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"/>
<field name="alias_name" class="oe_inline" attrs="{'required': [('id', '!=', False)]}"/>@<field name="alias_domain" class="oe_inline"/>
</div>
<group>
<group>

View File

@ -24,7 +24,7 @@
<field name="time_unit" domain="[('category_id.name','=','Working Time')]"/>
</group>
<group name="project_left_column">
<separator string="Planing" colspan="2"/>
<separator string="Planning" colspan="2"/>
<field name="module_project_long_term"/>
<separator string="Helpdesk and Support" colspan="2"/>
<field name="module_project_issue"/>

View File

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

View File

@ -376,10 +376,9 @@
</xpath>
<field name="priority" position="before">
<field name="project_escalation_id"/>
<field name="reply_to"/>
</field>
<field name="alias_model" position="attributes">
<attribute name="invisible" value="0"/>
<field name="alias_domain" position="after">
<label for="alias_model" class="oe_edit_only" string="creates"/><field name="alias_model" class="oe_edit_only oe_inline"/>
</field>
</field>
</record>