diff options
| author | Adrian Torres <adt@odoo.com> | 2019-03-28 14:01:54 +0000 |
|---|---|---|
| committer | Adrian Torres <adt@odoo.com> | 2019-04-05 13:10:35 +0000 |
| commit | 3f3d2b2773377c707be110aeb3edf9c8fd689d07 (patch) | |
| tree | 225ecdb651c8ea9bdd98bf6025e678be5116e35d /odoo/addons/base/module/module.py | |
| parent | a25abec95c434f01e10847950fe9301a4e910435 (diff) | |
[FIX] base: prevent module operations while cron is running
closes odoo/odoo#32234
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/addons/base/module/module.py')
| -rw-r--r-- | odoo/addons/base/module/module.py | 9 |
1 files changed, 9 insertions, 0 deletions
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() |
