[ADD] tests to get_root_ancestor
use a default view_type of form in the tests, because whatever bzr revid: xmo@openerp.com-20130423132523-upbgbt2a3r7cgs08
This commit is contained in:
parent
aef4ce51a7
commit
dd43214fe1
|
@ -2067,9 +2067,7 @@ class BaseModel(object):
|
||||||
:param inherit_id: the database view_id of the parent view
|
:param inherit_id: the database view_id of the parent view
|
||||||
:return: a modified source where all the modifying architecture
|
:return: a modified source where all the modifying architecture
|
||||||
are applied
|
are applied
|
||||||
|
|
||||||
"""
|
"""
|
||||||
View = self.pool['ir.ui.view']
|
|
||||||
return reduce(
|
return reduce(
|
||||||
lambda s, descendant: View.apply_inheritance_specs(
|
lambda s, descendant: View.apply_inheritance_specs(
|
||||||
cr, user, self._name, inherit_id, s, *descendant, context=context),
|
cr, user, self._name, inherit_id, s, *descendant, context=context),
|
||||||
|
|
|
@ -104,7 +104,9 @@ class TestViewInheritance(common.TransactionCase):
|
||||||
'model': self.model,
|
'model': self.model,
|
||||||
'name': name,
|
'name': name,
|
||||||
'arch': self.view_for(name),
|
'arch': self.view_for(name),
|
||||||
'inherit_id': parent, })
|
'inherit_id': parent,
|
||||||
|
'type': 'form',
|
||||||
|
})
|
||||||
self.ids[name] = view_id
|
self.ids[name] = view_id
|
||||||
return view_id
|
return view_id
|
||||||
|
|
||||||
|
@ -158,3 +160,22 @@ class TestViewInheritance(common.TransactionCase):
|
||||||
(self.ids[name], self.view_for(name))
|
(self.ids[name], self.view_for(name))
|
||||||
for name in ['A21', 'A22', 'A221']
|
for name in ['A21', 'A22', 'A221']
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_find_root(self):
|
||||||
|
A_id = self.ids['A']
|
||||||
|
root = self.View.get_root_ancestor(self.cr, self.uid, view_id=A_id)
|
||||||
|
self.assertEqual(root['id'], A_id,
|
||||||
|
"when given a root view, operation should be id")
|
||||||
|
|
||||||
|
root = self.View.get_root_ancestor(
|
||||||
|
self.cr, self.uid, view_id=self.ids['A11'])
|
||||||
|
self.assertEqual(root['id'], A_id)
|
||||||
|
|
||||||
|
root = self.View.get_root_ancestor(
|
||||||
|
self.cr, self.uid, view_id=self.ids['A221'])
|
||||||
|
self.assertEqual(root['id'], A_id)
|
||||||
|
|
||||||
|
# search by model
|
||||||
|
root = self.View.get_root_ancestor(
|
||||||
|
self.cr, self.uid, model=self.model, view_type='form')
|
||||||
|
self.assertEqual(root['id'], A_id)
|
||||||
|
|
Loading…
Reference in New Issue