Reviewers: ,
Please review this at http://codereview.tryton.org/689003/
Affected files:
M CHANGELOG
M doc/topics/views/index.rst
M trytond/ir/ui/tree.rnc
M trytond/ir/ui/tree.rng
M trytond/model/modelview.py
Index: CHANGELOG
===================================================================
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Add dynamic label
+* Add prefix, suffix on tree view
* Add selection_change_with on Selection and Reference fields
* Add Dict fields
* Remove unique constraint on model and field access
Index: doc/topics/views/index.rst
===================================================================
--- a/doc/topics/views/index.rst
+++ b/doc/topics/views/index.rst
@@ -159,7 +159,8 @@
* ``string``: The string that will be displayed in the label.
* ``name``: The name of the field whose description will be used for
- string.
+ string. Except if ``string`` is set, it will use this value and the
value
+ of the field if ``string`` is empty.
* ``id``: see common-attributes-id_.
@@ -491,6 +492,19 @@
* ``completion``: see in common-attributes-completion_.
+prefix or suffix
+^^^^^^^^^^^^^^^^
+
+A ``field`` could contain one or many ``prefix`` or ``suffix`` that will be
+diplayed in the same column.
+
+ * ``string``: The text that will be displayed.
+
+ * ``name``: The name of the field whose value will be displayed.
+
+ * ``icon``: The name of the field that contains the name of the icon to
+ display or the name of the icon.
+
Example
-------
Index: trytond/ir/ui/tree.rnc
===================================================================
--- a/trytond/ir/ui/tree.rnc
+++ b/trytond/ir/ui/tree.rnc
@@ -12,7 +12,7 @@
attlist.tree &= attribute colors { text }?
attlist.tree &=
[ a:defaultValue = "0" ] attribute keyword_open { "0" | "1" }?
-field = element field { attlist.field, empty }
+field = element field { attlist.field, (prefix | suffix)* }
attlist.field &= attribute name { text }
attlist.field &= attribute readonly { "0" | "1" }?
attlist.field &=
@@ -52,6 +52,11 @@
attlist.field &= attribute float_time { text }?
attlist.field &= [a:defaultValue = "0"] attribute pre_validate { "0" | "1"
}?
attlist.field &= [a:defaultValue = "1"] attribute completion { "0" | "1" }?
+prefix = element prefix { attlist.affix, empty }
+suffix = element suffix { attlist.affix, empty }
+attlist.affix &= attribute string { text }?
+attlist.affix &= attribute name { text }?
+attlist.affix &= attribute icon { text }?
button = element button { attlist.button, empty }
attlist.button &= attribute help { text }?
attlist.button &=
Index: trytond/ir/ui/tree.rng
===================================================================
--- a/trytond/ir/ui/tree.rng
+++ b/trytond/ir/ui/tree.rng
@@ -54,7 +54,12 @@
<define name="field">
<element name="field">
<ref name="attlist.field"/>
- <empty/>
+ <zeroOrMore>
+ <choice>
+ <ref name="prefix"/>
+ <ref name="suffix"/>
+ </choice>
+ </zeroOrMore>
</element>
</define>
<define name="attlist.field" combine="interleave">
@@ -167,6 +172,33 @@
</attribute>
</optional>
</define>
+ <define name="prefix">
+ <element name="prefix">
+ <ref name="attlist.affix"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="suffix">
+ <element name="suffix">
+ <ref name="attlist.affix"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="attlist.affix" combine="interleave">
+ <optional>
+ <attribute name="string"/>
+ </optional>
+ </define>
+ <define name="attlist.affix" combine="interleave">
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="attlist.affix" combine="interleave">
+ <optional>
+ <attribute name="icon"/>
+ </optional>
+ </define>
<define name="button">
<element name="button">
<ref name="attlist.button"/>
Index: trytond/model/modelview.py
===================================================================
--- a/trytond/model/modelview.py
+++ b/trytond/model/modelview.py
@@ -418,7 +418,8 @@
fields_attrs = copy.deepcopy(fields_attrs)
childs = True
- if element.tag in ('field', 'label', 'separator', 'group'):
+ if element.tag in
('field', 'label', 'separator', 'group', 'suffix',
+ 'prefix'):
for attr in ('name', 'icon'):
if element.get(attr):
fields_attrs.setdefault(element.get(attr), {})
--
--
[email protected] mailing list
---
You received this message because you are subscribed to the Google Groups "tryton-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.