[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.
This commit is contained in:
parent
f9d25973d0
commit
6e23b2a807
|
@ -954,13 +954,13 @@ class ir_model_data(osv.osv):
|
||||||
|
|
||||||
if action_id and res_id:
|
if action_id and res_id:
|
||||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
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'),
|
'date_update': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
},context=context)
|
},context=context)
|
||||||
elif res_id:
|
elif res_id:
|
||||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||||
if xml_id:
|
if xml_id:
|
||||||
self.create(cr, uid, {
|
self.create(cr, SUPERUSER_ID, {
|
||||||
'name': xml_id,
|
'name': xml_id,
|
||||||
'model': model,
|
'model': model,
|
||||||
'module':module,
|
'module':module,
|
||||||
|
@ -971,7 +971,7 @@ class ir_model_data(osv.osv):
|
||||||
for table in model_obj._inherits:
|
for table in model_obj._inherits:
|
||||||
inherit_id = model_obj.browse(cr, uid,
|
inherit_id = model_obj.browse(cr, uid,
|
||||||
res_id,context=context)[model_obj._inherits[table]]
|
res_id,context=context)[model_obj._inherits[table]]
|
||||||
self.create(cr, uid, {
|
self.create(cr, SUPERUSER_ID, {
|
||||||
'name': xml_id + '_' + table.replace('.', '_'),
|
'name': xml_id + '_' + table.replace('.', '_'),
|
||||||
'model': table,
|
'model': table,
|
||||||
'module': module,
|
'module': module,
|
||||||
|
@ -982,7 +982,7 @@ class ir_model_data(osv.osv):
|
||||||
if mode=='init' or (mode=='update' and xml_id):
|
if mode=='init' or (mode=='update' and xml_id):
|
||||||
res_id = model_obj.create(cr, uid, values, context=context)
|
res_id = model_obj.create(cr, uid, values, context=context)
|
||||||
if xml_id:
|
if xml_id:
|
||||||
self.create(cr, uid, {
|
self.create(cr, SUPERUSER_ID, {
|
||||||
'name': xml_id,
|
'name': xml_id,
|
||||||
'model': model,
|
'model': model,
|
||||||
'module': module,
|
'module': module,
|
||||||
|
@ -993,7 +993,7 @@ class ir_model_data(osv.osv):
|
||||||
for table in model_obj._inherits:
|
for table in model_obj._inherits:
|
||||||
inherit_id = model_obj.browse(cr, uid,
|
inherit_id = model_obj.browse(cr, uid,
|
||||||
res_id,context=context)[model_obj._inherits[table]]
|
res_id,context=context)[model_obj._inherits[table]]
|
||||||
self.create(cr, uid, {
|
self.create(cr, SUPERUSER_ID, {
|
||||||
'name': xml_id + '_' + table.replace('.', '_'),
|
'name': xml_id + '_' + table.replace('.', '_'),
|
||||||
'model': table,
|
'model': table,
|
||||||
'module': module,
|
'module': module,
|
||||||
|
|
Loading…
Reference in New Issue