[IMP] views: allow create/delete/edit attribte on form/tree/kanban views, automatically set the attributes from access rights.

bzr revid: vmt@openerp.com-20120813091047-vqjk3an52dfzbhqe
This commit is contained in:
Vo Minh Thu 2012-08-13 11:10:47 +02:00
parent 5ac8f97de0
commit 5e0f709410
2 changed files with 12 additions and 0 deletions

View File

@ -172,6 +172,9 @@
<rng:define name="form">
<rng:element name="form">
<rng:ref name="overload"/>
<rng:optional><rng:attribute name="create" /></rng:optional>
<rng:optional><rng:attribute name="delete" /></rng:optional>
<rng:optional><rng:attribute name="edit" /></rng:optional>
<rng:optional><rng:attribute name="string"/></rng:optional>
<rng:optional><rng:attribute name="type"/></rng:optional>
<rng:optional><rng:attribute name="link"/></rng:optional>
@ -220,6 +223,8 @@
<rng:attribute name="default_group_by" />
</rng:optional>
<rng:optional><rng:attribute name="create" /></rng:optional>
<rng:optional><rng:attribute name="delete" /></rng:optional>
<rng:optional><rng:attribute name="edit" /></rng:optional>
<rng:optional><rng:attribute name="quick_create" /></rng:optional>
<rng:zeroOrMore>
<rng:ref name="field"/>
@ -235,6 +240,9 @@
<rng:define name="tree">
<rng:element name="tree">
<rng:ref name="overload"/>
<rng:optional><rng:attribute name="create" /></rng:optional>
<rng:optional><rng:attribute name="delete" /></rng:optional>
<rng:optional><rng:attribute name="edit" /></rng:optional>
<rng:optional><rng:attribute name="string"/></rng:optional>
<rng:optional><rng:attribute name="colors"/></rng:optional>
<rng:optional><rng:attribute name="fonts"/></rng:optional>

View File

@ -1830,6 +1830,10 @@ class BaseModel(object):
fields = self.fields_get(cr, user, None, context)
fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
node = self._disable_workflow_buttons(cr, user, node)
if node.tag in ('kanban', 'tree', 'form'):
for a, b in (('create', 'check_create'), ('delete', 'check_unlink'), ('edit', 'check_write')):
if not node.get(a) and not getattr(self, b)(cr, user, raise_exception=False):
node.set(a, 'false')
arch = etree.tostring(node, encoding="utf-8").replace('\t', '')
for k in fields.keys():
if k not in fields_def: