Exemple #1
0
# Imports, for base primitives
from tryton_builder import Module, Model, Field, Relation

# We create a new module
module = Module('HelloWorld')

# Add a module dependence
module.add_dependence('party')

# Two models
hello = Model('Hello', 'hello.hello')
bye = Model('Bye', 'bye.bye')

# Add models to module
module.add_model(hello)
module.add_model(bye)

# Add Fields
hello.add_field(Field('Char', 'Name'))
hello.add_field(Field('Char', 'Greeting'))
hello.add_field(Field('Boolean', 'Is Happy'))
hello.add_field(Field('Date', 'Birthdate'))
hello.add_field(Field('Time', 'Wake Up Time'))
hello.add_field(Field('Binary', 'Some File'))

# Add Relation with party module
hello.add_field(Relation('Many2One', 'Party', 'party.party'))

# Fields for Bye module
bye.add_field(Field('Char', 'Name'))
bye.add_field(Field('Selection', 'Season', options=[
reunion.add_field(
    Field('Selection',
          'Type',
          options=['Ordinaria', 'Extraordinaria', 'Reunion']))
reunion.add_field(
    Field('Selection', 'Status', options=[
        'Planned',
        'Complete',
    ]))
reunion.add_field(Field('Date', 'Start Date'))
reunion.add_field(Field('Time', 'Start Time'))
reunion.add_field(Field('Time', 'End Time'))
# Campo para subir archivos
# Relacion con socios para los asistentes

# --------- Assignments ------------ #

module = Module('cooperative_ar')
module.add_dependence('company')
module.add_dependence('country')
module.add_dependence('party')

module.add_model(socio)
module.add_model(reunion)
module.add_model(vacations)

module.many2many(socio, reunion)
# Build!!
module.build()
# Our module is placed on HelloWorld dir
vacations.add_field(Relation("Many2One", "Partner", "cooperative.partner"))
# relacion many to many con Meetings

# --------- Meetings --------------- #

reunion = Model("Meeting", "cooperative.meeting")
reunion.add_field(Field("Selection", "Type", options=["Ordinaria", "Extraordinaria", "Reunion"]))
reunion.add_field(Field("Selection", "Status", options=["Planned", "Complete"]))
reunion.add_field(Field("Date", "Start Date"))
reunion.add_field(Field("Time", "Start Time"))
reunion.add_field(Field("Time", "End Time"))
# Campo para subir archivos
# Relacion con socios para los asistentes


# --------- Assignments ------------ #

module = Module("cooperative_ar")
module.add_dependence("company")
module.add_dependence("country")
module.add_dependence("party")

module.add_model(socio)
module.add_model(reunion)
module.add_model(vacations)

module.many2many(socio, reunion)
# Build!!
module.build()
# Our module is placed on HelloWorld dir