diff options
| author | Jigar Amin - OpenERP <jam@tinyerp.com> | 2012-07-03 14:16:20 +0530 |
|---|---|---|
| committer | Jigar Amin - OpenERP <jam@tinyerp.com> | 2012-07-03 14:16:20 +0530 |
| commit | 04fa87b2aa42e037f4793fb80c1932d0bbf84cd2 (patch) | |
| tree | c57cfa48e18dbf415aa35598e1d6eabc1d0b9c82 /openerp/tools/view_validation.py | |
| parent | 2666ab3fe024c162b2a9efacb540b214010fccc1 (diff) | |
| parent | 78ba98baa0dec11cd0514abd27140f27acb8b352 (diff) | |
[MERGE] lp:~openerp-commiter/openobject-server/trunk-sloppy-rng-jam-validation-aja
bzr revid: jam@tinyerp.com-20120703084620-aioarva0jgombwo4
Diffstat (limited to 'openerp/tools/view_validation.py')
| -rw-r--r-- | openerp/tools/view_validation.py | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/openerp/tools/view_validation.py b/openerp/tools/view_validation.py index 0f1609b8376..a1be317b371 100644 --- a/openerp/tools/view_validation.py +++ b/openerp/tools/view_validation.py @@ -4,9 +4,110 @@ def valid_page_in_book(arch): """A `page` node must be below a `book` node.""" return not arch.xpath('//page[not(ancestor::notebook)]') +def valid_field_in_graph(arch): + """A `field` node must be below a `graph` node.""" + return not arch.xpath('//graph[not(field)]') + +def valid_field_in_tree(arch): + """A `field` and `button` node must be below a `tree` node.""" + return not arch.xpath('//tree[not((field) and (button))]') + +def valid_att_in_field(arch): + """A `name` attribute must be in a `field` node.""" + return not arch.xpath('//field[not (@name)]') + +def valid_att_in_label(arch): + """A `for` and `string` attribute must be in a `lable` node.""" + return not arch.xpath('//label[not ((@for) or (@string))]') + +def valid_att_in_tree(arch): + """A `string` attribute must be in a `tree` node.""" + return not arch.xpath('//tree[not (@string)]') + +def valid_att_in_form(arch): + """A `string` attribute must be in a `form` node.""" + return not arch.xpath('//form[not (@string)]') + +def valid_att_in_graph(arch): + """A `string` attribute must be in a `graph` node.""" + return not arch.xpath('//graph[not (@string)]') + +def valid_type_in_colspan(arch): + """A `colspan` attribute must be an `integer` type.""" + for attrib in arch.xpath('//*/@colspan'): + try: + int(attrib) + except: + return False + return True + +def valid_type_in_col(arch): + """A `col` attribute must be an `integer` type.""" + for attrib in arch.xpath('//*/@col'): + try: + int(attrib) + except: + return False + return True + +def valid_colspan_view(arch): + for pred in [valid_type_in_colspan]: + if not pred(arch): + return False + return True + +def valid_col_view(arch): + for pred in [valid_type_in_col]: + if not pred(arch): + return False + return True + +def valid_field_view(arch): + for pred in [valid_att_in_field]: + if not pred(arch): + return False + return True + +def valid_label_view(arch): + for pred in [valid_att_in_label]: + if not pred(arch): + return False + return True + +def valid_tree_view(arch): + if arch.tag == 'tree': + for pred in [valid_att_in_tree]: + if not pred(arch): + return False + return True + +def valid_form_view(arch): + if arch.tag == 'form': + for pred in [valid_att_in_form]: + if not pred(arch): + return False + return True + +def valid_graph_view(arch): + if arch.tag == 'graph': + for pred in [valid_att_in_graph]: + if not pred(arch): + return False + return True + + def valid_view(arch): if arch.tag == 'form': for pred in [valid_page_in_book]: if not pred(arch): return False + elif arch.tag == 'graph': + for pred in [valid_field_in_graph]: + if not pred(arch): + return False + elif arch.tag == 'tree': + for pred in [valid_field_in_tree]: + if not pred(arch): + return False return True + |
