From bc3009d590af243ee28bb1e6994bcb2fae6d2bba Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 8 Oct 2012 14:03:51 +0200 Subject: [PATCH 01/15] [FIX] mail: default alias_domain should be web.base.url bzr revid: odo@openerp.com-20121008120351-fqmjckrjmy52xdji --- addons/mail/data/mail_demo.xml | 5 ----- addons/mail/res_config.py | 13 +++++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/mail/data/mail_demo.xml b/addons/mail/data/mail_demo.xml index 1350fd33547..7bda32c002b 100644 --- a/addons/mail/data/mail_demo.xml +++ b/addons/mail/data/mail_demo.xml @@ -42,10 +42,5 @@ This month you also get 250 EUR of eco-vouchers if you have been in the company comment - - mail.catchall.domain - demo.openerp.com - - diff --git a/addons/mail/res_config.py b/addons/mail/res_config.py index ce2f75687ba..91606e1c720 100644 --- a/addons/mail/res_config.py +++ b/addons/mail/res_config.py @@ -19,6 +19,8 @@ # ############################################################################## +import urlparse + from openerp.osv import osv, fields class project_configuration(osv.TransientModel): @@ -31,9 +33,16 @@ class project_configuration(osv.TransientModel): } def get_default_alias_domain(self, cr, uid, ids, context=None): - return {'alias_domain': self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)} + alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + if not alias_domain: + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.base.url", context=context) + try: + alias_domain = urlparse.urlsplit(domain).netloc.split(':')[0] + except Exception: + pass + return {'alias_domain': alias_domain} def set_alias_domain(self, cr, uid, ids, context=None): config_parameters = self.pool.get("ir.config_parameter") for record in self.browse(cr, uid, ids, context=context): - config_parameters.set_param(cr, uid, "mail.catchall.domain", record.alias_domain or '', context=context) \ No newline at end of file + config_parameters.set_param(cr, uid, "mail.catchall.domain", record.alias_domain or '', context=context) From 43595fbeb1f2020ab7e1f545c0dbf6a579bf77b2 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 8 Oct 2012 14:04:21 +0200 Subject: [PATCH 02/15] [FIX] mail: default email From should consider user email if there is no alias bzr revid: odo@openerp.com-20121008120421-k9aj7g6vsr3zu5u2 --- addons/mail/mail_mail.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index e9a569a8192..5b4a096e969 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -63,10 +63,12 @@ class mail_mail(osv.Model): } def _get_default_from(self, cr, uid, context=None): - cur = self.pool.get('res.users').browse(cr, uid, uid, context=context) - if not cur.alias_domain: - raise osv.except_osv(_('Invalid Action!'), _('Unable to send email, set an alias domain in your server settings.')) - return cur.alias_name + '@' + cur.alias_domain + this = self.pool.get('res.users').browse(cr, uid, uid, context=context) + if this.alias_domain: + return '%s@%s' % (this.alias, this.alias_domain) + elif this.email: + return this.email + raise osv.except_osv(_('Invalid Action!'), _("Unable to send email, please configure the sender's email address or alias.")) _defaults = { 'state': 'outgoing', From d54120565152cc0f1c8164bf7538802f7d527332 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 8 Oct 2012 15:02:45 +0200 Subject: [PATCH 03/15] [FIX] portal: add test email address for outgoing emails sent during tests bzr revid: odo@openerp.com-20121008130245-7n1ed3i2ez9bzniy --- addons/portal/tests/test_portal.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py index 653a05d40aa..10392be53ff 100644 --- a/addons/portal/tests/test_portal.py +++ b/addons/portal/tests/test_portal.py @@ -49,6 +49,9 @@ class test_portal(test_mail.TestMailMockups): self.user_chell = self.res_users.browse(cr, uid, self.user_chell_id) self.partner_chell_id = self.user_chell.partner_id.id + # Set an email address for the user running the tests, used as Sender for outgoing mails + self.res_users.write(cr, uid, uid, {'email': 'test@localhost'}) + def test_00_access_rights(self): """ Test basic mail_message and mail_group access rights for portal users. """ cr, uid = self.cr, self.uid From 635c3225dbf78dd6ff548b9f979f549a49a663da Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 8 Oct 2012 16:08:57 +0200 Subject: [PATCH 04/15] [FIX] project_long_term: demo project with phases should be marked as `use_phases` bzr revid: odo@openerp.com-20121008140857-zd3kcyq8t2ewyfno --- addons/project_long_term/project_long_term_demo.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/project_long_term/project_long_term_demo.xml b/addons/project_long_term/project_long_term_demo.xml index bca8231fdaa..fda481d5a11 100644 --- a/addons/project_long_term/project_long_term_demo.xml +++ b/addons/project_long_term/project_long_term_demo.xml @@ -7,6 +7,7 @@ + From 42ece6cdb779bfdaed041768736a521dbc2aadc3 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 9 Oct 2012 12:35:35 +0200 Subject: [PATCH 05/15] [FIX] project: leftover typos in mail processing methods bzr revid: odo@openerp.com-20121009103535-ohvpd1u81hcc5izi --- addons/project/project.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 6b02a018293..98c385c0ce3 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1173,11 +1173,10 @@ class task(base_stage, osv.osv): """ Override to updates the document according to the email. """ if custom_values is None: custom_values = {} custom_values.update({ - 'name': subject, + 'name': msg.get('subject'), 'planned_hours': 0.0, - 'subject': msg.get('subject'), }) - return super(project_tasks,self).message_new(cr, uid, msg, custom_values=custom_values, context=context) + return super(task,self).message_new(cr, uid, msg, custom_values=custom_values, context=context) def message_update(self, cr, uid, ids, msg, update_vals=None, context=None): """ Override to update the task according to the email. """ @@ -1202,7 +1201,7 @@ class task(base_stage, osv.osv): act = 'do_%s' % res.group(2).lower() if act: getattr(self,act)(cr, uid, ids, context=context) - return super(project_tasks,self).message_update(cr, uid, msg, update_vals=update_vals, context=context) + return super(task,self).message_update(cr, uid, msg, update_vals=update_vals, context=context) # --------------------------------------------------- # OpenChatter methods and notifications From 099825109ef0795693d6fce665891e0641d2766d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 9 Oct 2012 15:19:11 +0200 Subject: [PATCH 06/15] [FIX] mail.message: catch more error cases when trying to resolve msg author + lint cleanup bzr revid: odo@openerp.com-20121009131911-6lo2knsrh2qgrxv8 --- addons/mail/mail_message.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 9c873a31097..98b7ef9f36d 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -180,7 +180,6 @@ class mail_message(osv.Model): fields allow to have the foreign record name without having to check external access rights). """ - child_nbr = len(msg.child_ids) has_voted = False vote_ids = self.pool.get('res.users').name_get(cr, SUPERUSER_ID, [user.id for user in msg.vote_user_ids], context=context) for vote in vote_ids: @@ -194,7 +193,7 @@ class mail_message(osv.Model): try: author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] is_author = uid == msg.author_id.user_ids[0].id - except (orm.except_orm, osv.except_osv): + except Exception: author_id = False is_author = False try: From fac6e9246be0f03915c199a2f9277658dd501c95 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 9 Oct 2012 15:31:32 +0200 Subject: [PATCH 07/15] [FIX] mail: allow overriding message_post in threads + fix res.users' delegation to res.partner bzr revid: odo@openerp.com-20121009133132-at5j8pm8engxqi10 --- addons/mail/mail_thread.py | 2 +- addons/mail/res_users.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 9f53b4c08b1..8dee944751c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -427,7 +427,7 @@ class mail_thread(osv.AbstractModel): model_pool.message_update(cr, user_id, [thread_id], msg, context=context) else: thread_id = model_pool.message_new(cr, user_id, msg, custom_values, context=context) - self.message_post(cr, uid, [thread_id], context=context, **msg) + model_pool.message_post(cr, uid, [thread_id], context=context, **msg) return thread_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 545198f4c7f..f870604b03a 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -110,9 +110,19 @@ class res_users(osv.Model): alias_pool.unlink(cr, uid, alias_ids, context=context) return res - def message_post(self, cr, uid, thread_id, **kwargs): - partner_id = self.pool.get('res.users').browse(cr, uid, thread_id)[0].partner_id.id - return self.pool.get('res.partner').message_post(cr, uid, partner_id, **kwargs) + def message_post(self, cr, uid, thread_id, context=None, **kwargs): + assert thread_id, "res.users does not support posting global messages" + if context and 'thread_model' in context: + context['thread_model'] = 'res.partner' + if isinstance(thread_id, (list, tuple)): + thread_id = thread_id[0] + partner_id = self.pool.get('res.users').browse(cr, uid, thread_id).partner_id.id + return self.pool.get('res.partner').message_post(cr, uid, partner_id, context=context, **kwargs) + + def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None): + partner_id = self.pool.get('res.users').browse(cr, uid, ids)[0].partner_id.id + return self.pool.get('res.partner').message_update(cr, uid, [partner_id], msg_dict, + update_vals=update_vals, context=context) class res_users_mail_group(osv.Model): """ Update of res.users class From 0ce1ef32a872bd1f942dd73ee11214374b6ce520 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 9 Oct 2012 15:40:20 +0200 Subject: [PATCH 08/15] [FIX] mail: typos -> message-id header is mapped to message_id column bzr revid: odo@openerp.com-20121009134020-9wf96yszv8qcmbm1 --- addons/mail/mail_thread.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 8dee944751c..2261b940944 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -422,7 +422,7 @@ class mail_thread(osv.AbstractModel): model_pool = self.pool.get(model) assert thread_id and hasattr(model_pool, 'message_update') or hasattr(model_pool, 'message_new'), \ "Undeliverable mail with Message-Id %s, model %s does not accept incoming emails" % \ - (msg['message-id'], model) + (msg['message_id'], model) if thread_id and hasattr(model_pool, 'message_update'): model_pool.message_update(cr, user_id, [thread_id], msg, context=context) else: @@ -538,7 +538,7 @@ class mail_thread(osv.AbstractModel): field may not be present if missing in original message:: - { 'message-id': msg_id, + { 'message_id': msg_id, 'subject': subject, 'from': from, 'to': to, From cb57169c97fa8577d2b2e24789b563f2066f059e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 9 Oct 2012 15:44:14 +0200 Subject: [PATCH 09/15] [FIX] mail.mail: typo in previous commits bzr revid: odo@openerp.com-20121009134414-923kv1ciw00pxh6v --- addons/mail/mail_mail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 5b4a096e969..741184ef7a3 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -65,7 +65,7 @@ class mail_mail(osv.Model): def _get_default_from(self, cr, uid, context=None): this = self.pool.get('res.users').browse(cr, uid, uid, context=context) if this.alias_domain: - return '%s@%s' % (this.alias, this.alias_domain) + return '%s@%s' % (this.alias_name, this.alias_domain) elif this.email: return this.email raise osv.except_osv(_('Invalid Action!'), _("Unable to send email, please configure the sender's email address or alias.")) From 7f516d2835e3f2ba9a9b466d7ad4a92251566a20 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 9 Oct 2012 15:50:40 +0200 Subject: [PATCH 10/15] [FIX] mail.message: incorrect message-id generation, id/model were swapped For backwards-compatibility reasons we need to stick with this format: `res_id-model`, even if reversing the values would look more logical bzr revid: odo@openerp.com-20121009135040-spvejc1l4mos25yv --- addons/mail/mail_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 98b7ef9f36d..7e77b2f2e8c 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -501,7 +501,7 @@ class mail_message(osv.Model): def create(self, cr, uid, values, context=None): if not values.get('message_id') and values.get('res_id') and values.get('model'): - values['message_id'] = tools.generate_tracking_message_id('%(model)s-%(res_id)s' % values) + values['message_id'] = tools.generate_tracking_message_id('%(res_id)s-%(model)s' % values) newid = super(mail_message, self).create(cr, uid, values, context) self._notify(cr, SUPERUSER_ID, newid, context=context) return newid From fbbc0bad19c57bfbf5df9351373c8edd0ead3ded Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 9 Oct 2012 16:34:33 +0200 Subject: [PATCH 11/15] [IMP] all: replaced 'true' by 'True' in 'options' attribute in views, because now the syntax of these options must be expressed in python instead of json bzr revid: qdp-launchpad@openerp.com-20121009143433-s4y6isbewqdn2fu2 --- addons/account/account_invoice_view.xml | 2 +- addons/account/account_view.xml | 2 +- .../account_voucher/voucher_sales_purchase_view.xml | 2 +- addons/crm/crm_lead_view.xml | 12 ++++++------ addons/document_page/document_page_view.xml | 2 +- .../wizard/document_page_show_diff_view.xml | 2 +- .../wizard/email_template_preview_view.xml | 2 +- addons/event/event_view.xml | 4 ++-- addons/hr/hr_view.xml | 8 ++++---- addons/portal_crm/wizard/contact_view.xml | 4 ++-- addons/project/project_view.xml | 6 +++--- addons/project_gtd/project_gtd_view.xml | 4 ++-- addons/project_gtd/wizard/project_gtd_fill_view.xml | 2 +- addons/sale/sale_view.xml | 4 ++-- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 26e18271dc2..48737bd5fef 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -322,7 +322,7 @@ + options='{"always_reload": True}'/> diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 3391158696a..d2680a8456f 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -635,7 +635,7 @@ - + diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 4c388730644..a362c553ccd 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -73,7 +73,7 @@ - + diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index f91a8756598..f7acb6b557d 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -160,17 +160,17 @@
- +
- +
@@ -488,7 +488,7 @@
diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index 69567902763..caa893aea6e 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -42,14 +42,14 @@ - + - + @@ -57,14 +57,14 @@ - + - + diff --git a/addons/portal_crm/wizard/contact_view.xml b/addons/portal_crm/wizard/contact_view.xml index 1776632d7ab..778e7f9562e 100644 --- a/addons/portal_crm/wizard/contact_view.xml +++ b/addons/portal_crm/wizard/contact_view.xml @@ -35,8 +35,8 @@ - - + +

diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index bd63eec84c5..9d3b137f7c1 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -103,7 +103,7 @@ - + @@ -311,7 +311,7 @@ - +
@@ -401,7 +401,7 @@ - + diff --git a/addons/project_gtd/project_gtd_view.xml b/addons/project_gtd/project_gtd_view.xml index fdb8ae8495c..a7026da8854 100644 --- a/addons/project_gtd/project_gtd_view.xml +++ b/addons/project_gtd/project_gtd_view.xml @@ -92,8 +92,8 @@ - - + + diff --git a/addons/project_gtd/wizard/project_gtd_fill_view.xml b/addons/project_gtd/wizard/project_gtd_fill_view.xml index 8807c00a76b..626dfb699b8 100644 --- a/addons/project_gtd/wizard/project_gtd_fill_view.xml +++ b/addons/project_gtd/wizard/project_gtd_fill_view.xml @@ -8,7 +8,7 @@
- + diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 5505a6a88b5..0055deb8d3d 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -214,7 +214,7 @@