From 126b49075d595e954e7ce18400aaaa243cc7a343 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 26 Jun 2013 15:58:42 +0200 Subject: [PATCH 1/3] [FIX] Export creates xml id based on wrong table name lp bug: https://launchpad.net/bugs/1194893 fixed bzr revid: stefan@therp.nl-20130626135842-sdbvopuen0s7liv9 --- openerp/osv/orm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 499a21f8555..6aafd05e0bf 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -1106,7 +1106,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._table), ('res_id', '=', r['id'])]) if len(data_ids): d = model_data.read(cr, uid, data_ids, ['name', 'module'])[0] if d['module']: @@ -1116,13 +1116,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__', }) From 216f4d5e66452168b542f88adb703561c510f399 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 26 Jun 2013 16:04:39 +0200 Subject: [PATCH 2/3] [FIX] Do not search for model = table name in previous commit bzr revid: stefan@therp.nl-20130626140439-3emprb4ewc2xlcsy --- openerp/osv/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 6aafd05e0bf..cfd811a80dc 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -1106,7 +1106,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._model._table), ('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']: From 62ea0bb3831cd5b5c60b69d4ee8d93e3bd679415 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Thu, 24 Oct 2013 23:47:35 +0200 Subject: [PATCH 3/3] [FIX] Update test for external id bzr revid: stefan@therp.nl-20131024214735-emciqtcm6vrs9xda --- openerp/tests/addons/test_impex/tests/test_export.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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]])