summaryrefslogtreecommitdiff
path: root/odoo/addons/base/models/ir_module.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-04-10 15:10:24 +0200
committerChristophe Simonis <chs@odoo.com>2019-04-10 15:10:24 +0200
commite145f2b0c8831ec8756307b6b70c82f8dcdcab54 (patch)
tree93406d01e313cfecdeac03132c1cccb55ff05088 /odoo/addons/base/models/ir_module.py
parent3f95b074e959f0f4ac93fbf4048c0c7276f2c17a (diff)
parent2694174b410f14ca81f0681ff4ae6856ff459ced (diff)
[MERGE] forward port branch saas-12.2 up to 2694174b410
Diffstat (limited to 'odoo/addons/base/models/ir_module.py')
-rw-r--r--odoo/addons/base/models/ir_module.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py
index 27c81dd2702..ddccfb2c3ca 100644
--- a/odoo/addons/base/models/ir_module.py
+++ b/odoo/addons/base/models/ir_module.py
@@ -19,6 +19,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
import odoo
from odoo import api, fields, models, modules, tools, _
@@ -542,6 +543,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()