From a3de5c872f7c26ec085dc62b95cfc62382ab970a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 9 Apr 2013 13:11:58 +0200 Subject: [REF] [IMP] mail_alias improvement alias_name is not required anymore crm, hr_job, project, mail_group, res_users: alias creation is now different and done more like other inherits, except an alias_model_name that is given to the context to find the alias alias_model_id. crm, jr_job, project, mail_group, res_users: updated form views using aliases mail_alias: added a filter on 'inactive' aliases (alias_name False) and added a button to redirect to the related document if any bzr revid: tde@openerp.com-20130409111158-bv04n5o01z9l3c17 --- addons/mail/mail_group.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'addons/mail/mail_group.py') diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 977608f487e..28cc7be5c52 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -100,10 +100,10 @@ class mail_group(osv.Model): header = '' if group.description: header = '%s' % group.description - if group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain: + if group.alias_id and group.alias_name and group.alias_domain: if header: header = '%s
' % header - return '%sGroup email gateway: %s@%s' % (header, group.alias_id.alias_name, group.alias_id.alias_domain) + return '%sGroup email gateway: %s@%s' % (header, group.alias_name, group.alias_domain) return header def _subscribe_users(self, cr, uid, ids, context=None): @@ -114,15 +114,8 @@ class mail_group(osv.Model): self.message_subscribe(cr, uid, ids, partner_ids, context=context) def create(self, cr, uid, vals, context=None): - mail_alias = self.pool.get('mail.alias') - if not vals.get('alias_id'): - vals.pop('alias_name', None) # prevent errors during copy() - alias_id = mail_alias.create_unique_alias(cr, uid, - # Using '+' allows using subaddressing for those who don't - # have a catchall domain setup. - {'alias_name': "group+" + vals['name']}, - model_name=self._name, context=context) - vals['alias_id'] = alias_id + if context is None: + context = {} # get parent menu menu_parent = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'mail_group_root') @@ -134,8 +127,10 @@ class mail_group(osv.Model): vals['menu_id'] = menu_id # Create group and alias - mail_group_id = super(mail_group, self).create(cr, uid, vals, context=context) - mail_alias.write(cr, uid, [vals['alias_id']], {"alias_force_thread_id": mail_group_id}, context) + create_context = dict(context, alias_model_name=self._name) + mail_group_id = super(mail_group, self).create(cr, uid, vals, context=create_context) + group = self.browse(cr, uid, mail_group_id, context=context) + self.pool.get('mail.alias').write(cr, uid, [group.alias_id.id], {"alias_force_thread_id": mail_group_id}, context) group = self.browse(cr, uid, mail_group_id, context=context) # Create client action for this group and link the menu to it -- cgit v1.2.3 From 88e3505554038350ae0274e9359bbffff342b9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 16 May 2013 18:42:07 +0200 Subject: [IMP] mail_alias: added reference to the parent record. The parent record is the record that holds the alias. It is different from the record updated or created using the alias. For example projects have aliases whose parent is the given projet, and that creates new task inside the project. Updated alias creation and management accordingly. This ownership concept is used to compute the 'followers' contact settings of aliases. bzr revid: tde@openerp.com-20130516164207-1zr0q6abw6a34ndf --- addons/mail/mail_group.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'addons/mail/mail_group.py') diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 28cc7be5c52..e0fff496e25 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -93,7 +93,6 @@ class mail_group(osv.Model): 'public': 'groups', 'group_public_id': _get_default_employee_group, 'image': _get_default_image, - 'alias_domain': False, # always hide alias during creation } def _generate_header_description(self, cr, uid, group, context=None): @@ -127,10 +126,10 @@ class mail_group(osv.Model): vals['menu_id'] = menu_id # Create group and alias - create_context = dict(context, alias_model_name=self._name) + create_context = dict(context, alias_model_name=self._name, alias_parent_model_name=self._name) mail_group_id = super(mail_group, self).create(cr, uid, vals, context=create_context) group = self.browse(cr, uid, mail_group_id, context=context) - self.pool.get('mail.alias').write(cr, uid, [group.alias_id.id], {"alias_force_thread_id": mail_group_id}, context) + self.pool.get('mail.alias').write(cr, uid, [group.alias_id.id], {"alias_force_thread_id": mail_group_id, 'alias_parent_thread_id': mail_group_id}, context) group = self.browse(cr, uid, mail_group_id, context=context) # Create client action for this group and link the menu to it -- cgit v1.2.3