summaryrefslogtreecommitdiff
path: root/odoo/service
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2017-05-03 11:43:05 +0200
committerRaphael Collet <rco@odoo.com>2017-05-03 15:41:05 +0200
commitb59318ec12a1ce4e59de6d7bcde7146545b6c044 (patch)
treef1c23d20305c2dfae87e3f2ad27e6fa525c00f27 /odoo/service
parent1458f1b3135d373dac0625c7d4bd4a7eea3eaf54 (diff)
[REF] registry: always perform registry/cache signaling at the end of request
Problem: the update of custom models/fields is not fully transactional, and may potentially lead to an inconsistent database. An other problem is creating two custom fields by writing on a model: if the second one fails, the first one has been committed without notice. Retrying the request will give an unexpected error (duplicate field name). Solution: never commit in the middle of a request. If the changes have an impact on the registry, then mark it as invalid (with a new flag), and signal registry invalidation after everything has been committed. If the request fails, reset the registry. Both registry and cache invalidation are handled the same way.
Diffstat (limited to 'odoo/service')
-rw-r--r--odoo/service/model.py4
-rw-r--r--odoo/service/report.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/odoo/service/model.py b/odoo/service/model.py
index 9ceab82b452..ba243bf432c 100644
--- a/odoo/service/model.py
+++ b/odoo/service/model.py
@@ -36,8 +36,8 @@ def dispatch(method, params):
security.check(db,uid,passwd)
registry = odoo.registry(db).check_signaling()
fn = globals()[method]
- res = fn(db, uid, *params)
- registry.signal_caches_change()
+ with registry.manage_changes():
+ res = fn(db, uid, *params)
return res
def check(f):
diff --git a/odoo/service/report.py b/odoo/service/report.py
index faac5521b99..8229a2396e4 100644
--- a/odoo/service/report.py
+++ b/odoo/service/report.py
@@ -32,8 +32,8 @@ def dispatch(method, params):
security.check(db,uid,passwd)
registry = odoo.registry(db).check_signaling()
fn = globals()['exp_' + method]
- res = fn(db, uid, *params)
- registry.signal_caches_change()
+ with registry.manage_changes():
+ res = fn(db, uid, *params)
return res
def exp_render_report(db, uid, object, ids, datas=None, context=None):