[FIX] handling of empty/absent modules in xids
Restore behaviour of not adding the separating dot if the module field of an ir.model.data record is empty. This is useful/important for interop with external systems.
This commit is contained in:
@@ -28,6 +28,23 @@ class CreatorCase(common.TransactionCase):
|
||||
record.invalidate_cache()
|
||||
return record._export_rows([f.split('/') for f in fields])
|
||||
|
||||
class test_xids(CreatorCase):
|
||||
model_name = 'export.boolean'
|
||||
|
||||
def test_no_module(self):
|
||||
record = self.make(True)
|
||||
# add existing xid without module
|
||||
self.env['ir.model.data'].create({
|
||||
'module': '',
|
||||
'name': 'x',
|
||||
'model': self.model_name,
|
||||
'res_id': record.id,
|
||||
})
|
||||
record.invalidate_cache()
|
||||
self.assertEqual(
|
||||
record._export_rows([['id'], ['value']]),
|
||||
[[u'x', u'True']]
|
||||
)
|
||||
|
||||
class test_boolean_field(CreatorCase):
|
||||
model_name = 'export.boolean'
|
||||
|
||||
+5
-2
@@ -647,12 +647,15 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
res_id: (module, name)
|
||||
for res_id, module, name in cr.fetchall()
|
||||
}
|
||||
def to_xid(record_id):
|
||||
(module, name) = xids[record_id]
|
||||
return ('%s.%s' % (module, name)) if module else name
|
||||
|
||||
# create missing xml ids
|
||||
missing = self.filtered(lambda r: r.id not in xids)
|
||||
if not missing:
|
||||
return (
|
||||
(record, '%s.%s' % xids[record.id])
|
||||
(record, to_xid(record.id))
|
||||
for record in self
|
||||
)
|
||||
|
||||
@@ -681,7 +684,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
self.env['ir.model.data'].invalidate_cache(fnames=fields)
|
||||
|
||||
return (
|
||||
(record, '%s.%s' % xids[record.id])
|
||||
(record, to_xid(record.id))
|
||||
for record in self
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user