-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathtestfile.xml
108 lines (108 loc) · 6.35 KB
/
testfile.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<form>
<!-- readonly should give: -->
<!-- (field1 == 'yes' and field2 != parent.some_field) or (field3 == uid or 'some-string'.lower() in field4.lower()) or 'yes' not in field5 and field6 == 'yes' -->
<field string="foo" attrs="{'invisible': True, 'readonly': ['|', '|', '&', ('field1', '=', 'yes'), ('field2', '!=', parent.some_field), '|', ('field3', '=', uid), ('field4', '=ilike', 'some-string'), ('field5', 'not like', 'yes'), ('field6', '=', 'yes')], 'required': [('field', 'in', ['a', 'b', 'c']), ('otherfield', '=?', some_field)], 'column_invisible': 0}" name="name"/>
<xpath expr="//." position="attributes">
<attribute name="attrs">{'invisible': True, 'readonly': [('otherfield', '=', 'yes')], 'required': [('field', 'in', ['a', 'b', 'c'])], 'column_invisible': 0}</attribute>
</xpath>
<!-- all leafs should evaluate to '[not] <some|other>' -->
<xpath expr="//field[@name='test1']" position="attributes">
<attribute name="attrs">{'invisible': [('some', '=', False), ('other', '!=', False)], 'readonly': [('some', '=', True), ('other', '!=', True)], 'required': [('some', '=', []), ('other', '!=', [])], 'column_invisible': [('some', '=', 'str'), ('other', '!=', 'str')]}</attribute>
<attribute name="indent_test"/>
</xpath>
<!-- field tag with both attrs (invisible, readonly) and states -->
<field name="test1" states="draft,done" attrs="{'invisible': True, 'readonly': True}"/>
<!-- field tag with both attrs (readonly, required) and states, with a double required attribute -->
<field required="1" name="test2" states="draft,done" attrs="{'readonly': True, 'required': [('otherfield', '=', 'yes')]}"/>
<!-- field tag with only attrs (invisible, readonly)-->
<field name="test3" attrs="{'invisible': True, 'readonly': True}"/>
<!-- field tag with only attrs (readonly) -->
<field name="test4" attrs="{'readonly': True}"/>
<!-- field tag with only states -->
<field name="test5" states="draft,done"/>
<!-- non-field tag with both attrs (invisible) and states -->
<group name="test6" states="draft,done" attrs="{'invisible': True}"/>
<!-- non-field tag with only attrs -->
<group name="test7" attrs="{'invisible': True}"/>
<!-- non-field tag with only states -->
<group name="test8" states="draft,done"/>
<!-- test conversion of special characters-->
<field name="test9" attrs="{'readonly': [('a', '>', 0), ('b', '<', 0), ('c', '>', 0)]}"/>
<!-- xpath override of field with both attrs (invisible) and states -->
<xpath expr="//field[@name='test5']" position="attributes">
<attribute name="attrs">{
'invisible': [
'|',
'|',
'&',
('test1', 'in', [1, 2, 3]),
('test2', 'in', [2, 3, 4]),
('test3', '=', 'hello'),
('test4', 'in', [%(testmodule.test_xml_id)d, %(testmodule.test_xml_id_2)d])
]
}</attribute>
<attribute name="states">draft,done</attribute>
</xpath>
<!-- xpath override of field with both attrs (required, invisible) and states and double required attribute -->
<xpath expr="//field[@name='test6']">
<attribute name="attrs">{'required': True, 'invisible': [('testfield', '=', 'hello world')]}</attribute>
<attribute name="states">draft,done</attribute>
<attribute name="required">1</attribute>
</xpath>
<!-- xpath override of field with only attrs (invisible) -->
<xpath expr="//field[@name='test7']">
<attribute name="attrs">{'invisible': True}</attribute>
</xpath>
<!-- xpath override of field with only states -->
<xpath expr="//field[@name='test8']">
<attribute name="states">draft,done</attribute>
</xpath>
<!-- xpath override of field with empty attrs and non-empty states -->
<xpath expr="//field[@name='test9']">
<attribute name="attrs"></attribute>
<attribute name="states">draft,done</attribute>
</xpath>
<!-- xpath override of field with non-empty attrs (required, invisible) and empty states -->
<xpath expr="//field[@name='test10']">
<attribute name="indent_test"/>
<attribute name="attrs">{'required': True, 'invisible': True}</attribute>
<attribute name="states"></attribute>
</xpath>
<!-- xpath override of field with empty attrs and empty states -->
<xpath expr="//field[@name='test11']">
<attribute name="attrs"></attribute>
<attribute name="states"></attribute>
</xpath>
<!-- xpath override of non-field with both attrs (invisible) and states -->
<xpath expr="//sheet/group[@name='test12']">
<attribute name="attrs">{'invisible': True}</attribute>
<attribute name="states">draft,done</attribute>
</xpath>
<!-- xpath override of non-field with only attrs (invisible) -->
<xpath expr="//sheet/group[@name='test13']">
<attribute name="attrs">{'invisible': True}</attribute>
</xpath>
<!-- xpath override of non-field with only states -->
<xpath expr="//sheet/group[@name='test14']">
<attribute name="states">draft,done</attribute>
</xpath>
<!-- field tag with only attrs (invisible) -->
<field name="test9" attrs="{
'invisible': [
'|',
'|',
'&',
('test1', 'in', [1, 2, 3]),
('test2', 'in', [2, 3, 4]),
('test3', '=', 'hello'),
('test4', 'in', [%(testmodule.test_xml_id)d, %(testmodule.test_xml_id_2)d])
]
}"/>
<!-- non-field tag with only attrs (invisible) -->
<group name="test10" attrs="{'invisible': True}"/>
<!-- Case given by odoo, single '|' with states - can cause bug while should be accepted -->
<button name="action_open_action_coupon_program" attrs="{'invisible': ['|', ('allow_modification', '=', False)]}" context="{'enable_add_temporary': 1}" class="btn btn-secondary" string="Actions" type="object" states="draft,sent,sale"/>
</form>
</odoo>