From a25abec95c434f01e10847950fe9301a4e910435 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Thu, 4 Apr 2019 10:12:46 +0000 Subject: [PATCH 1/4] [FIX] orm: don't crash on index creation For existing installations, creating indices might not always be possible, e.g. if you have a Text/Char field that has an index=True set on it in a field override and pre-existing rows longer than the pg supported size , the index creation will fail. Instead of failing miserably during the schema modification, simply log the problem instead and keep going. closes odoo/odoo#32442 Signed-off-by: Raphael Collet (rco) --- odoo/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/odoo/models.py b/odoo/models.py index feef5cc414f..de5fb780cda 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -2488,7 +2488,11 @@ class BaseModel(object): cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = %s and tablename = %s", (indexname, self._table)) res2 = cr.dictfetchall() if not res2 and field.index: - cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (self._table, name, self._table, name)) + try: # DO NOT FORWARD-PORT TO SAAS-15 AND UP (stop at saas-14) + with cr.savepoint(): + cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (self._table, name, self._table, name)) + except psycopg2.OperationalError as e: + _schema.error('Unable to add index for %s (%s):\n %s', self._table, name, e.message) cr.commit() if field.type == 'text': # FIXME: for fields.text columns we should try creating GIN indexes instead (seems most suitable for an ERP context) From 3f3d2b2773377c707be110aeb3edf9c8fd689d07 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Thu, 28 Mar 2019 14:01:54 +0000 Subject: [PATCH 2/4] [FIX] base: prevent module operations while cron is running closes odoo/odoo#32234 Signed-off-by: Raphael Collet (rco) --- odoo/addons/base/module/module.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/odoo/addons/base/module/module.py b/odoo/addons/base/module/module.py index 4145389ff7f..5ff5930499c 100644 --- a/odoo/addons/base/module/module.py +++ b/odoo/addons/base/module/module.py @@ -16,6 +16,7 @@ from docutils.core import publish_string from docutils.transforms import Transform, writer_aux from docutils.writers.html4css1 import Writer import lxml.html +import psycopg2 try: from cStringIO import StringIO @@ -479,6 +480,14 @@ class Module(models.Model): @api.multi def _button_immediate_function(self, function): + try: + # This is done because the installation/uninstallation/upgrade can modify a currently + # running cron job and prevent it from finishing, and since the ir_cron table is locked + # during execution, the lock won't be released until timeout. + self._cr.execute("SELECT * FROM ir_cron FOR UPDATE NOWAIT") + except psycopg2.OperationalError: + raise UserError(_("The server is busy right now, module operations are not possible at" + " this time, please try again later.")) function(self) self._cr.commit() From 6431e366a8e29e367d1908177b706bd8418d9d41 Mon Sep 17 00:00:00 2001 From: SimoRubi Date: Wed, 3 Apr 2019 08:48:26 +0000 Subject: [PATCH 3/4] [FIX] web: call method with correct record _compute_website_url can only be called on singletons It should not be called with self but the record we are iterating on closes odoo/odoo#32369 Signed-off-by: Martin Trigaux (mat) --- addons/website/models/ir_actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/models/ir_actions.py b/addons/website/models/ir_actions.py index 7d5c831a9fd..1c2c19d4bf6 100644 --- a/addons/website/models/ir_actions.py +++ b/addons/website/models/ir_actions.py @@ -39,7 +39,7 @@ class ServerAction(models.Model): def _get_website_url(self): for action in self: if action.state == 'code' and action.website_published: - action.website_url = self._compute_website_url(action.website_path, action.xml_id) + action.website_url = action._compute_website_url(action.website_path, action.xml_id) @api.model def _get_eval_context(self, action): From 32c2af2376c27dc078206725f0c94697e237e8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 12 Feb 2019 15:55:55 +0100 Subject: [PATCH 4/4] [FIX] mass_mailing: correctly find partner email in mass mailing In mass mailing access to partners when performing a mass mailing has been done in batch to speedup computation [1]. Emails are put into a dictionary allowing to find back the email based on partner_id. However the matching between the partner and its emails is done using a shortcut using the current document ID as partner ID. It works when performing a mass mailing on partners but fails when performing a mass mailing on models having message_get_default_recipients not returning only emails. Currently in saas-14 main models return only emails (crm, event, mailing contacts) but other models may encounter issues (applicants, tickets). This commit fixes it by correctly matching partner id and its found email. [1] See 65ed4553a50fdbefc986b7d21f87a81c42b743c7 --- addons/mass_mailing/wizard/mail_compose_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py index 6c1fc81280e..030ba1f7320 100644 --- a/addons/mass_mailing/wizard/mail_compose_message.py +++ b/addons/mass_mailing/wizard/mail_compose_message.py @@ -62,7 +62,8 @@ class MailComposeMessage(models.TransientModel): if mail_values.get('email_to'): recips = tools.email_split(mail_values['email_to']) else: - recips = tools.email_split(partners_email.get(res_id)) + partner_id = (mail_values.get('recipient_ids') or [(False, '')])[0][1] + recips = tools.email_split(partners_email.get(partner_id)) mail_to = recips[0].lower() if recips else False if (blacklist and mail_to in blacklist) or (seen_list and mail_to in seen_list): # prevent sending to blocked addresses that were included by mistake