From 6e23b2a8073b5ac1b7c74bf6bb98893d3983cea7 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 8 May 2015 10:17:44 +0200 Subject: [PATCH] [FIX] ir.model.data._update: create/modify XML IDs as super-user When importing a CSV file with an "id" column containing external IDs (XML IDs), the system automatically creates or updates the corresponding ir.model.data entries. This would fail for regular users who do not have create/write access on this internal model. --- openerp/addons/base/ir/ir_model.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index fb8e1db2fd5..69fd4db6380 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -954,13 +954,13 @@ class ir_model_data(osv.osv): if action_id and res_id: model_obj.write(cr, uid, [res_id], values, context=context) - self.write(cr, uid, [action_id], { + self.write(cr, SUPERUSER_ID, [action_id], { 'date_update': time.strftime('%Y-%m-%d %H:%M:%S'), },context=context) elif res_id: model_obj.write(cr, uid, [res_id], values, context=context) if xml_id: - self.create(cr, uid, { + self.create(cr, SUPERUSER_ID, { 'name': xml_id, 'model': model, 'module':module, @@ -971,7 +971,7 @@ class ir_model_data(osv.osv): for table in model_obj._inherits: inherit_id = model_obj.browse(cr, uid, res_id,context=context)[model_obj._inherits[table]] - self.create(cr, uid, { + self.create(cr, SUPERUSER_ID, { 'name': xml_id + '_' + table.replace('.', '_'), 'model': table, 'module': module, @@ -982,7 +982,7 @@ class ir_model_data(osv.osv): if mode=='init' or (mode=='update' and xml_id): res_id = model_obj.create(cr, uid, values, context=context) if xml_id: - self.create(cr, uid, { + self.create(cr, SUPERUSER_ID, { 'name': xml_id, 'model': model, 'module': module, @@ -993,7 +993,7 @@ class ir_model_data(osv.osv): for table in model_obj._inherits: inherit_id = model_obj.browse(cr, uid, res_id,context=context)[model_obj._inherits[table]] - self.create(cr, uid, { + self.create(cr, SUPERUSER_ID, { 'name': xml_id + '_' + table.replace('.', '_'), 'model': table, 'module': module,