[FIX] Import : Context of the action/screen passed,taken into consideration while importing
bzr revid: jvo@tinyerp.com-20091005121029-6sy1k3uvkpi2i8of
This commit is contained in:
parent
f822efa074
commit
f590b74318
|
@ -445,10 +445,11 @@ class ir_model_data(osv.osv):
|
|||
id = False
|
||||
return id
|
||||
|
||||
def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False):
|
||||
def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False, context=None):
|
||||
warning = True
|
||||
model_obj = self.pool.get(model)
|
||||
context = {}
|
||||
if not context:
|
||||
context = {}
|
||||
if xml_id and ('.' in xml_id):
|
||||
assert len(xml_id.split('.'))==2, _('"%s" contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id') % (xml_id)
|
||||
warning = False
|
||||
|
@ -471,12 +472,12 @@ class ir_model_data(osv.osv):
|
|||
res_id,action_id = res_id2,action_id2
|
||||
|
||||
if action_id and res_id:
|
||||
model_obj.write(cr, uid, [res_id], values)
|
||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||
self.write(cr, uid, [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)
|
||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||
if xml_id:
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
|
@ -484,21 +485,21 @@ class ir_model_data(osv.osv):
|
|||
'module':module,
|
||||
'res_id':res_id,
|
||||
'noupdate': noupdate,
|
||||
})
|
||||
},context=context)
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cr, uid,
|
||||
res_id)[model_obj._inherits[table]]
|
||||
res_id,context=context)[model_obj._inherits[table]]
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id + '_' + table.replace('.', '_'),
|
||||
'model': table,
|
||||
'module': module,
|
||||
'res_id': inherit_id,
|
||||
'noupdate': noupdate,
|
||||
})
|
||||
},context=context)
|
||||
else:
|
||||
if mode=='init' or (mode=='update' and xml_id):
|
||||
res_id = model_obj.create(cr, uid, values)
|
||||
res_id = model_obj.create(cr, uid, values, context=context)
|
||||
if xml_id:
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
|
@ -506,18 +507,18 @@ class ir_model_data(osv.osv):
|
|||
'module': module,
|
||||
'res_id': res_id,
|
||||
'noupdate': noupdate
|
||||
})
|
||||
},context=context)
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cr, uid,
|
||||
res_id)[model_obj._inherits[table]]
|
||||
res_id,context=context)[model_obj._inherits[table]]
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id + '_' + table.replace('.', '_'),
|
||||
'model': table,
|
||||
'module': module,
|
||||
'res_id': inherit_id,
|
||||
'noupdate': noupdate,
|
||||
})
|
||||
},context=context)
|
||||
if xml_id:
|
||||
if res_id:
|
||||
self.loads[(module, xml_id)] = (model, res_id)
|
||||
|
|
|
@ -577,6 +577,7 @@ class orm_template(object):
|
|||
raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),))
|
||||
if not line[i]:
|
||||
continue
|
||||
|
||||
field = fields[i]
|
||||
if (len(field)==len(prefix)+1) and field[len(prefix)].endswith(':db_id'):
|
||||
# Database ID
|
||||
|
@ -811,7 +812,7 @@ class orm_template(object):
|
|||
try:
|
||||
id = ir_model_data_obj._update(cr, uid, self._name,
|
||||
current_module, res, xml_id=data_id, mode=mode,
|
||||
noupdate=noupdate, res_id=res_id)
|
||||
noupdate=noupdate, res_id=res_id, context=context)
|
||||
except Exception, e:
|
||||
import psycopg2
|
||||
if isinstance(e,psycopg2.IntegrityError):
|
||||
|
|
Loading…
Reference in New Issue