_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' "
'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': '{}',
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']),
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