summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2014-02-26 14:37:16 +0100
committerMartin Trigaux <mat@openerp.com>2014-02-26 14:37:16 +0100
commit43df0b4d23fc6a93edab8d8f335dcc7d70d36962 (patch)
tree66e829ce74ec163c121011869165ea214f958ac5
parentbf51816215de971363f5747db13927ddda1d5b4f (diff)
parent62ea0bb3831cd5b5c60b69d4ee8d93e3bd679415 (diff)
[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
-rw-r--r--openerp/osv/orm.py6
-rw-r--r--openerp/tests/addons/test_impex/tests/test_export.py5
2 files changed, 6 insertions, 5 deletions
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 7fa71ac8f3a..3cc8320edb3 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -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__',
})
diff --git a/openerp/tests/addons/test_impex/tests/test_export.py b/openerp/tests/addons/test_impex/tests/test_export.py
index 26219b36d3b..995d69471d6 100644
--- a/openerp/tests/addons/test_impex/tests/test_export.py
+++ b/openerp/tests/addons/test_impex/tests/test_export.py
@@ -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]])