From 71b146d0ad43b66f2121aa38ff2621f686975fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 21 Mar 2014 18:16:15 +0100 Subject: [IMP] mail: mail_thread: added a method that try to find some default recipients for a document. Basically it looks for a partner_id field, or an email_from, or an email field, and return a dict result used for populating a creation dictionary, for example. bzr revid: tde@openerp.com-20140321171615-ksce5mqzyugya8hs --- addons/mail/mail_thread.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index f2d33be7787..c5bec47d573 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -661,6 +661,21 @@ class mail_thread(osv.AbstractModel): # Email specific #------------------------------------------------------ + def message_get_default_recipients(self, cr, uid, ids, context=None): + res = dict.fromkeys(ids, False) + for record in self.browse(cr, uid, ids, context=context): + recipient_ids, email_to = list(), '' + if self._name == 'res.partner': + recipient_ids.append(record.id) + elif 'partner_id' in self._all_columns and record.partner_id: + recipient_ids.append(record.parent_id.id) + elif 'email_from' in self._all_columns and record.email_from: + email_to = record.email_from + elif 'email' in self._all_columns: + email_to = record.email + res[record.id] = {'recipient_ids': recipient_ids, 'email_to': email_to} + return res + def message_get_reply_to(self, cr, uid, ids, context=None): """ Returns the preferred reply-to email address that is basically the alias of the document, if it exists. """ -- cgit v1.2.3 From 73bebb6563b1bd9d031ffc28d73fcce084df90a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 25 Mar 2014 14:53:47 +0100 Subject: [IMP] mail: default recipients management - mail.compose.message: in render_message_batch, compute defaults recipients for the composer (method called for mass mailing only). This way values are available for inheriting models. bzr revid: tde@openerp.com-20140325135347-9v7u4uokffy7ud43 --- addons/mail/mail_thread.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index c5bec47d573..86dbe50d302 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -662,18 +662,19 @@ class mail_thread(osv.AbstractModel): #------------------------------------------------------ def message_get_default_recipients(self, cr, uid, ids, context=None): - res = dict.fromkeys(ids, False) - for record in self.browse(cr, uid, ids, context=context): - recipient_ids, email_to = list(), '' - if self._name == 'res.partner': - recipient_ids.append(record.id) - elif 'partner_id' in self._all_columns and record.partner_id: - recipient_ids.append(record.parent_id.id) + model = self + if context and context.get('thread_model'): + model = self.pool[context['thread_model']] + res = {} + for record in model.browse(cr, SUPERUSER_ID, ids, context=context): + recipient_ids, email_to, email_cc = set(), False, False + if 'partner_id' in self._all_columns and record.partner_id: + recipient_ids.add(record.parent_id.id) elif 'email_from' in self._all_columns and record.email_from: email_to = record.email_from elif 'email' in self._all_columns: email_to = record.email - res[record.id] = {'recipient_ids': recipient_ids, 'email_to': email_to} + res[record.id] = {'partner_ids': list(recipient_ids), 'email_to': email_to, 'email_cc': email_cc} return res def message_get_reply_to(self, cr, uid, ids, context=None): @@ -681,10 +682,9 @@ class mail_thread(osv.AbstractModel): the alias of the document, if it exists. """ if not self._inherits.get('mail.alias'): return [False for id in ids] - return ["%s@%s" % (record['alias_name'], record['alias_domain']) - if record.get('alias_domain') and record.get('alias_name') - else False - for record in self.read(cr, SUPERUSER_ID, ids, ['alias_name', 'alias_domain'], context=context)] + return ["%s@%s" % (record.alias_name, record.alias_domain) + if record.alias_domain and record.alias_name else False + for record in self.browse(cr, SUPERUSER_ID, ids, context=context)] #------------------------------------------------------ # Mail gateway -- cgit v1.2.3 From 3eaeae55a03da0244d5eef821dfa81cd0c911764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 15 Apr 2014 17:47:00 +0200 Subject: [IMP] mail, mass_mailing: better recipientsz computation for mass mailing, composer and template. This allows to have one method computing recipints and avoid repetiting myself. bzr revid: tde@openerp.com-20140415154700-zu2izvxfjq1k4h4a --- addons/mail/mail_thread.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index a4bc8002a04..53e4017951c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -662,14 +662,15 @@ class mail_thread(osv.AbstractModel): #------------------------------------------------------ def message_get_default_recipients(self, cr, uid, ids, context=None): - model = self - if context and context.get('thread_model'): - model = self.pool[context['thread_model']] + if context and context.get('thread_model') and context['thread_model'] in self.pool and context['thread_model'] != self._name: + sub_ctx = dict(context) + sub_ctx.pop('thread_model') + return self.pool[context['thread_model']].message_get_default_recipients(cr, uid, ids, context=sub_ctx) res = {} - for record in model.browse(cr, SUPERUSER_ID, ids, context=context): + for record in self.browse(cr, SUPERUSER_ID, ids, context=context): recipient_ids, email_to, email_cc = set(), False, False if 'partner_id' in self._all_columns and record.partner_id: - recipient_ids.add(record.parent_id.id) + recipient_ids.add(record.partner_id.id) elif 'email_from' in self._all_columns and record.email_from: email_to = record.email_from elif 'email' in self._all_columns: -- cgit v1.2.3 From 4336c64a7c5ddfe1a185a2b683b6fe47122f9d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 16 Apr 2014 10:28:51 +0200 Subject: [IMP] mail, mass_mailing: using a _mail_mass_mailing class attribute it is now possible to compute models allowing mass mailing using mass_mailing_campaign module. This allows to completely remove the bridges modules, using a more generic controller for unsubscription. bzr revid: tde@openerp.com-20140416082851-8duo6yrwr5hwd8c2 --- addons/mail/mail_thread.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 53e4017951c..8ea28cbbf75 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -96,6 +96,9 @@ class mail_thread(osv.AbstractModel): # :param function lambda: returns whether the tracking should record using this subtype _track = {} + # Mass mailing feature + _mail_mass_mailing = False + def get_empty_list_help(self, cr, uid, help, context=None): """ Override of BaseModel.get_empty_list_help() to generate an help message that adds alias information. """ -- cgit v1.2.3 From 75850c8f954e2e77e2a395cc9ff078743d96fc79 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 16 Apr 2014 16:37:55 +0200 Subject: [ADD] *: replace overriden methods get_formview_action by get_formview_id Methods to override to specify the view/action to launch for many2one links get_formview_action use get_formview_id to find the view to open. Therefore, it is simplier to override get_formview_id to tell which view should be opened bzr revid: dle@openerp.com-20140416143755-07slguqn6zadqsg5 --- addons/mail/mail_thread.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'addons/mail/mail_thread.py') diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 1d7e6730427..112dff6bac6 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -588,23 +588,6 @@ class mail_thread(osv.AbstractModel): model_obj.check_access_rights(cr, uid, check_operation) model_obj.check_access_rule(cr, uid, mids, check_operation, context=context) - def _get_formview_action(self, cr, uid, id, model=None, context=None): - """ Return an action to open the document. This method is meant to be - overridden in addons that want to give specific view ids for example. - - :param int id: id of the document to open - :param string model: specific model that overrides self._name - """ - return { - 'type': 'ir.actions.act_window', - 'res_model': model or self._name, - 'view_type': 'form', - 'view_mode': 'form', - 'views': [(False, 'form')], - 'target': 'current', - 'res_id': id, - } - def _get_inbox_action_xml_id(self, cr, uid, context=None): """ When redirecting towards the Inbox, choose which action xml_id has to be fetched. This method is meant to be inherited, at least in portal @@ -647,10 +630,7 @@ class mail_thread(osv.AbstractModel): if model_obj.check_access_rights(cr, uid, 'read', raise_exception=False): try: model_obj.check_access_rule(cr, uid, [res_id], 'read', context=context) - if not hasattr(model_obj, '_get_formview_action'): - action = self.pool.get('mail.thread')._get_formview_action(cr, uid, res_id, model=model, context=context) - else: - action = model_obj._get_formview_action(cr, uid, res_id, context=context) + action = model_obj.get_formview_action(cr, uid, res_id, context=context) except (osv.except_osv, orm.except_orm): pass action.update({ -- cgit v1.2.3