summaryrefslogtreecommitdiff
path: root/odoo/modules/db.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2018-06-19 12:11:59 +0200
committerXavier Morel <xmo@odoo.com>2018-07-16 11:44:32 +0200
commit93c0d7e811da0e64d03bfea0f131c6ace1fbde05 (patch)
tree9f2816352b39523e1828281fde3f208d613dcdd7 /odoo/modules/db.py
parent233874d5efa00529a6d23a33a8b0b75d535e1950 (diff)
[IMP] de-commit-ify db/module install
Try to remove cr.commit (and rollback) from module and db install: * put a savepoint around test data loading * remove a bunch of commits sprinkled throughout * remove rollback on data loading failure (assuming it bubbles up, the entire module's installation should be rolled back) * add commit right before the tests are run, so they can run isolated and still see whatever was done when installing their module * convert a few explicit closing to context managers
Diffstat (limited to 'odoo/modules/db.py')
-rw-r--r--odoo/modules/db.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/odoo/modules/db.py b/odoo/modules/db.py
index 8cdd7273e6b..f7e91a01282 100644
--- a/odoo/modules/db.py
+++ b/odoo/modules/db.py
@@ -27,12 +27,9 @@ def initialize(cr):
m = "File not found: 'base.sql' (provided by module 'base')."
_logger.critical(m)
raise IOError(m)
- base_sql_file = odoo.tools.misc.file_open(f)
- try:
+
+ with odoo.tools.misc.file_open(f) as base_sql_file:
cr.execute(base_sql_file.read())
- cr.commit()
- finally:
- base_sql_file.close()
for i in odoo.modules.get_modules():
mod_path = odoo.modules.get_module_path(i)
@@ -84,8 +81,6 @@ def initialize(cr):
if not to_auto_install: break
cr.execute("""UPDATE ir_module_module SET state='to install' WHERE name in %s""", (tuple(to_auto_install),))
- cr.commit()
-
def create_categories(cr, categories):
""" Create the ir_module_category entries for some categories.