[IMP] added the mail model field and improved the name_Getr
bzr revid: jam@tinyerp.com-20120704052212-3z4mhsmuj6038v7r
This commit is contained in:
parent
ab75f9b5a9
commit
37ad1cb683
|
@ -39,6 +39,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 +71,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 +91,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,13 +105,9 @@ 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
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<sheet>
|
||||
<group colspan="4" col="4">
|
||||
<field name="alias_name"/>
|
||||
<field name="alias_domain"/>
|
||||
<field name="alias_model_id" readonly="1"/>
|
||||
<field name="alias_user_id"/>
|
||||
<field name="alias_force_thread_id"/>
|
||||
|
|
Loading…
Reference in New Issue