A Tryton Module Creation Crash Course Defining Some Object / Tables Defining a Tree and a Form View Default Values N

A Tryton Module Creation Crash Course Defining Some Object / Tables Defining a Tree and a Form View Default Values N

Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module A minimal module A tryton module creation crash course Defining some object / tables Defining a tree and a form view Default values N. Évrard Some more advanced features Workflows B2CK Buttons Function fields Wizards Extending Tryton Unconference Leipzig 2014 pre-existing tryton objects Extending models Extending views Outline Tryton Crash Course 1 Installing tryton N. Évrard Prerequisites Installing tryton Initializing tryton Prerequisites Initializing tryton 2 A basic module A basic module A minimal module A minimal module Defining some object / tables Defining some object / tables Defining a tree and a form view Defining a tree and a form view Default values Default values Some more advanced features 3 Some more advanced features Workflows Buttons Workflows Function fields Wizards Buttons Extending Function fields pre-existing tryton objects Wizards Extending models Extending views 4 Extending pre-existing tryton objects Extending models Extending views Python good practices (pip & virtualenv) Tryton Crash Course N. Évrard Installing tryton Prerequisites pip is THE tool for installing and managing Python packages. Initializing tryton virtualenv is THE tool used to create isolated Python environment. A basic module A minimal module create isolated Python environments Defining some object / tables Do not mix different version of your libraries / applications Defining a tree and a form view Installation of packages in the user $HOME Default values Some more pip install virtualenv (or your distro package manager) advanced features Workflows virtualenv --system-site-packages .venv/trytond Buttons Function fields source .venv/trytond/bin/activate Wizards Extending hgnested is a mercurial extension. The tryton project use it to easily pre-existing tryton objects apply the same command on nested repositories. Extending models Extending views Installing trytond Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module Example A minimal module Defining some object / tables Defining a tree and a $ hg nclone http://hg.tryton.org/trytond -b 3.4 form view Default values $ cd trytond Some more $ pip install -e . advanced features Workflows $ pip install vobject Buttons Function fields Wizards Extending pre-existing tryton objects Extending models Extending views Setting up a trytond config file Tryton Crash Course N. Évrard Here is a minimal example of a configuration file. You should save it in $HOME/.trytond.conf Installing tryton Prerequisites Initializing tryton Example A basic module A minimal module Defining some object / tables [database] Defining a tree and a form view path = /home/training/databases Default values Some more advanced features Workflows Buttons We will set the TRYTOND_CONFIG environment variable Function fields Wizards Example Extending pre-existing tryton objects Extending models $ export TRYTOND_CONFIG=$HOME/.trytond.conf Extending views Initializing a minimal trytond database Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module Example A minimal module Defining some object / tables Defining a tree and a $ touch ~/databases/test.sqlite form view Default values $ ./bin/trytond -d test -u ir res Some more advanced features Workflows Buttons Function fields trytond will ask you for the admin password at the end of the installation Wizards process. Extending pre-existing tryton objects Extending models Extending views Adding a new modules Tryton Crash Course N. Évrard Installing tryton Prerequisites In this tutorial we will use a MQ repository in order to progress step by Initializing tryton step. A basic module A minimal module Defining some object / Example tables Defining a tree and a form view Default values $ cd trytond/modules Some more advanced features $ hg init training Workflows $ cd training/.hg Buttons Function fields $ hg clone http://hg.tryton.org/training -b 3.4 patches Wizards Extending pre-existing tryton objects Extending models Extending views A minimal trytond modules Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module A minimal module Defining some object / A minimal trytond modules needs two files: tables Defining a tree and a form view __init__.py the usual file needed by all python modules Default values tryton.cfg the file that helps tryton glue together model and view Some more advanced features definitions Workflows Buttons Function fields Wizards Extending pre-existing tryton objects Extending models Extending views The content of tryton.cfg Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton Example A basic module A minimal module Defining some object / tables [tryton] Defining a tree and a form view version=0.0.1 Default values depends: Some more advanced features ir Workflows Buttons res Function fields Wizards Extending pre-existing tryton objects Extending models Extending views Creating a model Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module A minimal module Example Defining some object / tables Defining a tree and a from trytond .model import ModelSQL form view Default values __all__ = [ ’Opportunity’] Some more class Opportunity (ModelSQL): advanced features ’Opportunity ’ Workflows __name__ = ’training.opportunity ’ Buttons Function fields Wizards Extending pre-existing tryton objects Extending models Extending views Register the model Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module A minimal module Example Defining some object / tables Defining a tree and a from trytond.pool import Pool form view from .opportunity import ∗ Default values def register (): Some more Pool.register( advanced features Opportunity , Workflows module=’training ’ , type_=’model’) Buttons Function fields Wizards Extending pre-existing tryton objects Extending models Extending views Adding fields to a model Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module Example A minimal module Defining some object / class Opportunity (ModelSQL): tables ’Opportunity ’ Defining a tree and a __name__ = ’training.opportunity ’ form view _rec_name = ’description ’ Default values description = fields.Char( ’Description ’, required=True) Some more start_date = fields.Date( ’Start Date’, advanced features required=True) Workflows end_date = fields.Date( ’End Date’) Buttons party = fields.Many2One( ’party.party ’, ’Party ’ , required=True) Function fields comment = fields .Text( ’Comment’) Wizards Extending pre-existing tryton objects Extending models Extending views Displaying data Tryton Crash Course N. Évrard To use the presentation layer your model must inherit from ModelView Installing tryton Prerequisites Initializing tryton Example A basic module class Opportunity(ModelSQL, ModelView): A minimal module Defining some object / tables Defining a tree and a form view You must also add the xml presentation file in the tryton.cfg Default values configuration file Some more advanced features Workflows Example Buttons Function fields Wizards xml: Extending pre-existing tryton opportunity.xml objects Extending models Extending views Defining a view Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module A minimal module Defining some object / trytond/ir/ui/view.py tables View objects are normal tryton objects ( ) Defining a tree and a form view Two kind of view: Default values Some more Tree view a list of record advanced features Form view a view for editing/creating one record Workflows Buttons Function fields Wizards Extending pre-existing tryton objects Extending models Extending views A tree view Tryton Crash Course N. Évrard Installing tryton Prerequisites Example Initializing tryton A basic module <record model=" ir .ui.view" id="opportunity_view_list"> A minimal module <field name="model">training .opportunity</ field> <field name="type">tree</ field> Defining some object / tables <field name="name">opportunity_list</ field> < / record> Defining a tree and a form view Default values Some more advanced features Example Workflows Buttons <tree string="Opportunities"> Function fields <field name="party"/> Wizards <field name="description"/> <field name="start_date"/> Extending <field name="end_date"/> pre-existing tryton < / t r e e > objects Extending models Extending views A form view Tryton Crash Course N. Évrard Example Installing tryton Prerequisites <record model=" ir .ui.view" id="opportunity_view_form"> Initializing tryton <field name="model">training .opportunity</ field> <field name="type">form</ field> A basic module <field name="name">opportunity_form</ field> A minimal module < / record> Defining some object / tables Defining a tree and a form view Default values Example Some more advanced features <form string="Opportunity"> Workflows <label name="party"/> Buttons <field name="party"/> Function fields <label name="description"/> <field name="description"/> Wizards <label name="start_date"/> Extending <field name="start_date"/> pre-existing tryton <label name="end_date" /> objects <field name="end_date"/> <separator name="comment" colspan="4" /> Extending models <field name="comment" colspan="4"/> Extending views < / form> Adding default values Tryton Crash Course N. Évrard Installing tryton Prerequisites Initializing tryton A basic module Create a method in the object with the name default_<field_name> A minimal module Defining some object / tables Example

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    29 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us