From e74c12ffe2f0ced4d5e67e9377e0934bae54fa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 18 Nov 2015 15:57:57 +0100 Subject: [PATCH 1/5] [FIX] hr_holidays: mailing deadlock / spam Some fixes coming from V9 revision 2be1dfc1ed7c9814cd3dbf4eb4cc95f842f738c2. The purpose is to avoid to send emails in batch and to limitate automatic subscription. - add a context key to use the email queue for notifications linked to allocations created in batch. This way emails will be send asynchronously and will not create a deadlock when having a lot of allocations to process. - also fixed a missing context in a browse --- addons/hr_holidays/hr_holidays.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 99319658392..52ea1849196 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -325,7 +325,7 @@ class hr_holidays(osv.osv): """ Override to avoid automatic logging of creation """ if context is None: context = {} - context = dict(context, mail_create_nolog=True) + context = dict(context, mail_create_nolog=True, mail_create_nosubscribe=True) if values.get('state') and values['state'] not in ['draft', 'confirm', 'cancel'] and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_user'): raise osv.except_osv(_('Warning!'), _('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % values.get('state')) return super(hr_holidays, self).create(cr, uid, values, context=context) @@ -393,7 +393,8 @@ class hr_holidays(osv.osv): elif record.holiday_type == 'category': emp_ids = obj_emp.search(cr, uid, [('category_ids', 'child_of', [record.category_id.id])]) leave_ids = [] - for emp in obj_emp.browse(cr, uid, emp_ids): + batch_context = dict(context, mail_notify_force_send=False) + for emp in obj_emp.browse(cr, uid, emp_ids, context=context): vals = { 'name': record.name, 'type': record.type, @@ -406,7 +407,7 @@ class hr_holidays(osv.osv): 'parent_id': record.id, 'employee_id': emp.id } - leave_ids.append(self.create(cr, uid, vals, context=None)) + leave_ids.append(self.create(cr, uid, vals, context=batch_context)) for leave_id in leave_ids: # TODO is it necessary to interleave the calls? for sig in ('confirm', 'validate', 'second_validate'): From af6305722fd3a67be43547c3a759a3584d898d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 23 Oct 2015 16:19:50 +0200 Subject: [PATCH 2/5] [FIX] mail: server action: do not send directly email notifications This is a backport of a fix in 9, revision 890f1302c7175e24887e66a2f8b973e72fb4c7e9. In this revision a context key is added wshen evaluating server actions. Notification emails created during a server action will be set in the queue and not send directly. --- addons/email_template/ir_actions.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/email_template/ir_actions.py b/addons/email_template/ir_actions.py index 3e7d2c1c67a..5304b6f6cbc 100644 --- a/addons/email_template/ir_actions.py +++ b/addons/email_template/ir_actions.py @@ -79,5 +79,18 @@ class actions_server(osv.Model): force_send=False, raise_exception=False, context=context) return False + def _get_eval_context(self, cr, uid, action, context=None): + """ Override the method giving the evaluation context but also the + context used in all subsequent calls. Add the mail_notify_force_send + key set to False in the context. This way all notification emails linked + to the currently executed action will be set in the queue instead of + sent directly. This will avoid possible break in transactions. """ + eval_context = super(actions_server, self)._get_eval_context(cr, uid, action, context=context) + # re-dictify, because eval_context['context'] is a frozendict + ctx = dict(eval_context.get('context', {})) + ctx['mail_notify_force_send'] = False + eval_context['context'] = ctx + return eval_context + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 8fa73181781babbf09ab655ba13ae81ce4ec7064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 23 Nov 2015 16:31:40 +0100 Subject: [PATCH 3/5] [FIX] project, issue: change user_id + date_start project.task: use an onchange to update date_start when changing user_id. Indeed date_start is automatically updated in the create / write. Without the onchange, this may lead to errors related to date_start being greater then date_end. project.issue: code in create and write now takes into account date_open values given to the method and avoid erasing them. In issue however the onchange is not added. Indeed the date_open and date_closed fields are not visible in the view. They are automatically computed and used to compute statistics. --- addons/project/project_view.xml | 1 + addons/project_issue/project_issue.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 925a440a1ba..e1f211da844 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -396,6 +396,7 @@ Date: Tue, 24 Nov 2015 10:22:16 +0100 Subject: [PATCH 4/5] [FIX] account: when a payment is processed in the bank interface, it will complete the partner automatically if a single invoice is found with the same reference. As expected for a structured communication for example. Fixes opw 653452 --- addons/account/account_bank_statement.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index c193eb48a03..c85f48a83f1 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -531,8 +531,9 @@ class account_bank_statement_line(osv.osv): ('reconcile_id', '=', False), ('state', '=', 'valid'), ('account_id.reconcile', '=', True), - ('id', 'not in', excluded_ids), - ('partner_id', 'in', (False, st_line.partner_id.id))] + ('id', 'not in', excluded_ids),] + if st_line.partner_id: + domain.append(('partner_id', '=', st_line.partner_id.id)) return domain def get_reconciliation_proposition(self, cr, uid, st_line, excluded_ids=None, context=None): From 3e03cfe7ac82cd8df3dd5819b1c730706dc6451d Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 24 Nov 2015 16:09:00 +0100 Subject: [PATCH 5/5] [FIX] website: type openerp -> odoo opw-657169 --- addons/website/static/src/xml/website.editor.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml index 50b6cf03b8c..2e0370a889d 100644 --- a/addons/website/static/src/xml/website.editor.xml +++ b/addons/website/static/src/xml/website.editor.xml @@ -63,7 +63,7 @@ + id="link-external" placeholder="https://www.odoo.com"/>