This document discusses some lesser known features of Tryton including:
1. Adding currency or percentage symbols in tree views using the <suffix> tag
2. Conditionally applying view inheritance using the <domain> tag
3. Updating multiple field values like onchange using the @ModelView.button_change decorator
4. Checking for recursion in a tree hierarchy using the check_recursion() method
5. Returning search information using the search_global() method
2. ● Let’s talk about some of the least frequently used Tryton features.
●
● If you don’t know they exist, you cannot take advantage of them!
0/Tryton Unfrequently Given Answers
3. ● Use it to add a currency or percentage symbol in tree views:
●
● <tree>
● <field name="percentage">
● <suffix name="percentage" string="%"/>
● </field>
● </tree>
●
● http://doc.tryton.org/4.6/trytond/doc/topics/views/index.html?
highlight=suffix
1/prefix & suffix
4. ● Allows you to apply a view inheritance conditionally. Example: Show a
field to some users only.
●
● Although it is named “domain” it actually is a PySON expression.
●
● <record model=”ir.ui.view” id=”xxxx”>
● <field name=”model”>model.name</field>
● <field name=”type”>form</field>
● <field name=”domain” eval=”Eval(‘context’, {}).get(‘user’) == 1”
pyson=”1”/>
● <field name=”name”>model_name_form</field>
● </record>
2/ir.ui.view domain
5. ● Allows you to update the value of several fields just like on_change.
●
● Data is not stored before the button is pushed.
●
● @ModelView.button_change(‘field1’, ‘field2’)
● def update_fields(self):
● self.field3 = self.field1 + self.field2
3/button_change
6. ● Provided by ModelStorage (which ModelSQL inherits)
●
● Use this method to check a tree hierarchy has no loops.
4/check_recursion()
7. ● Model method to return information to be shown in Global Search
5/search_global()
8. ● Use werkzeug routes
●
● Grant access to some routes to apps
●
● http://doc.tryton.org/4.6/trytond/doc/topics/user_application.html
6/user_application
10. ● Open URLs with the browser
●
● Should be possible to open tryton:// URLs.
8/URL Actions
11. ● Icons are loaded once when the user logs in with the corresponding
client.
●
● <record model="ir.ui.icon" id="contract_icon">
● <field name="name">tryton-contract</field>
● <field name="path">icons/tryton-contract.svg</field>
● </record>
●
● <menuitem id="menu_contract" name="Contracts" icon="tryton-
contract"/>
9/Icons & Images