[MERGE] [FIX] orm: when generating xml ids for export, use the model of the exported field instead of the current model. Courtesy of Stefan Rijnhart (Therp).
bzr revid: mat@openerp.com-20140226133716-vgdjjmqc2lou0n3u
This commit is contained in:
commit
43df0b4d23
|
@ -1119,7 +1119,7 @@ class BaseModel(object):
|
|||
|
||||
def _get_xml_id(self, cr, uid, r):
|
||||
model_data = self.pool.get('ir.model.data')
|
||||
data_ids = model_data.search(cr, uid, [('model', '=', r._table_name), ('res_id', '=', r['id'])])
|
||||
data_ids = model_data.search(cr, uid, [('model', '=', r._model._name), ('res_id', '=', r['id'])])
|
||||
if len(data_ids):
|
||||
d = model_data.read(cr, uid, data_ids, ['name', 'module'])[0]
|
||||
if d['module']:
|
||||
|
@ -1129,13 +1129,13 @@ class BaseModel(object):
|
|||
else:
|
||||
postfix = 0
|
||||
while True:
|
||||
n = self._table+'_'+str(r['id']) + (postfix and ('_'+str(postfix)) or '' )
|
||||
n = r._model._table+'_'+str(r['id']) + (postfix and ('_'+str(postfix)) or '' )
|
||||
if not model_data.search(cr, uid, [('name', '=', n)]):
|
||||
break
|
||||
postfix += 1
|
||||
model_data.create(cr, SUPERUSER_ID, {
|
||||
'name': n,
|
||||
'model': self._name,
|
||||
'model': r._model._name,
|
||||
'res_id': r['id'],
|
||||
'module': '__export__',
|
||||
})
|
||||
|
|
|
@ -309,8 +309,9 @@ class test_m2o(CreatorCase):
|
|||
def test_external_id(self):
|
||||
integer_id = self.registry('export.integer').create(
|
||||
self.cr, openerp.SUPERUSER_ID, {'value': 42})
|
||||
# __export__.$class.$id
|
||||
external_id = u'__export__.export_many2one_%d' % integer_id
|
||||
# Expecting the m2o target model name in the external id,
|
||||
# not this model's name
|
||||
external_id = u'__export__.export_integer_%d' % integer_id
|
||||
self.assertEqual(
|
||||
self.export(integer_id, fields=['value/id']),
|
||||
[[external_id]])
|
||||
|
|
Loading…
Reference in New Issue