[IMP] prevent changing a view from application: always to application: disabled
not sure that's actually useful, and can still go always -> enabled -> disabled...
This commit is contained in:
parent
d82ffb8728
commit
e2f41d09ba
|
@ -258,6 +258,14 @@ class view(osv.osv):
|
||||||
if custom_view_ids:
|
if custom_view_ids:
|
||||||
self.pool.get('ir.ui.view.custom').unlink(cr, uid, custom_view_ids)
|
self.pool.get('ir.ui.view.custom').unlink(cr, uid, custom_view_ids)
|
||||||
|
|
||||||
|
if vals.get('application') == 'disabled':
|
||||||
|
from_always = self.search(
|
||||||
|
cr, uid, [('id', 'in', ids), ('application', '=', 'always')], context=context)
|
||||||
|
if from_always:
|
||||||
|
raise ValueError(
|
||||||
|
"Can't disable views %s marked as always applied" % (
|
||||||
|
', '.join(map(str, from_always))))
|
||||||
|
|
||||||
self.read_template.clear_cache(self)
|
self.read_template.clear_cache(self)
|
||||||
ret = super(view, self).write(
|
ret = super(view, self).write(
|
||||||
cr, uid, ids,
|
cr, uid, ids,
|
||||||
|
|
|
@ -1069,18 +1069,21 @@ class TestOptionalViews(ViewCase):
|
||||||
'model': 'a',
|
'model': 'a',
|
||||||
'inherit_id': self.v0,
|
'inherit_id': self.v0,
|
||||||
'application': 'always',
|
'application': 'always',
|
||||||
|
'priority': 10,
|
||||||
'arch': '<xpath expr="//base" position="after"><v1/></xpath>',
|
'arch': '<xpath expr="//base" position="after"><v1/></xpath>',
|
||||||
})
|
})
|
||||||
self.v2 = self.create({
|
self.v2 = self.create({
|
||||||
'model': 'a',
|
'model': 'a',
|
||||||
'inherit_id': self.v0,
|
'inherit_id': self.v0,
|
||||||
'application': 'enabled',
|
'application': 'enabled',
|
||||||
|
'priority': 9,
|
||||||
'arch': '<xpath expr="//base" position="after"><v2/></xpath>',
|
'arch': '<xpath expr="//base" position="after"><v2/></xpath>',
|
||||||
})
|
})
|
||||||
self.v3 = self.create({
|
self.v3 = self.create({
|
||||||
'model': 'a',
|
'model': 'a',
|
||||||
'inherit_id': self.v0,
|
'inherit_id': self.v0,
|
||||||
'application': 'disabled',
|
'application': 'disabled',
|
||||||
|
'priority': 8,
|
||||||
'arch': '<xpath expr="//base" position="after"><v3/></xpath>'
|
'arch': '<xpath expr="//base" position="after"><v3/></xpath>'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1097,6 +1100,47 @@ class TestOptionalViews(ViewCase):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_applied_state_toggle(self):
|
||||||
|
""" Change application states of v2 and v3, check that the results
|
||||||
|
are as expected
|
||||||
|
"""
|
||||||
|
self.browse(self.v2).write({'application': 'disabled'})
|
||||||
|
arch = self.read_combined(self.v0)['arch']
|
||||||
|
self.assertEqual(
|
||||||
|
ET.fromstring(arch),
|
||||||
|
E.qweb(
|
||||||
|
E.base(),
|
||||||
|
E.v1(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.browse(self.v3).write({'application': 'enabled'})
|
||||||
|
arch = self.read_combined(self.v0)['arch']
|
||||||
|
self.assertEqual(
|
||||||
|
ET.fromstring(arch),
|
||||||
|
E.qweb(
|
||||||
|
E.base(),
|
||||||
|
E.v1(),
|
||||||
|
E.v3(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.browse(self.v2).write({'application': 'enabled'})
|
||||||
|
arch = self.read_combined(self.v0)['arch']
|
||||||
|
self.assertEqual(
|
||||||
|
ET.fromstring(arch),
|
||||||
|
E.qweb(
|
||||||
|
E.base(),
|
||||||
|
E.v1(),
|
||||||
|
E.v2(),
|
||||||
|
E.v3(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_mandatory_no_disabled(self):
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
self.browse(self.v1).write({'application': 'disabled'})
|
||||||
|
|
||||||
class TestXPathExtentions(common.BaseCase):
|
class TestXPathExtentions(common.BaseCase):
|
||||||
def test_hasclass(self):
|
def test_hasclass(self):
|
||||||
tree = E.node(
|
tree = E.node(
|
||||||
|
|
Loading…
Reference in New Issue