Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Some more layout examples

See Introduction to layouts

Tabbed forms

If the main panel of a FormLayout is horizontal (i.e.) doesn’t contain any newline, then the Layout will be rendered as a tabbed panel.

class InvoiceDetail(dd.FormLayout):
    main = "general more accounting"

    totals = dd.Panel("""
    # discount
    total_base
    total_vat
    total_incl
    workflow_buttons
    """,label=_("Totals"))

    invoice_header = dd.Panel("""
    date partner vat_regime
    order subject your_ref
    payment_term due_date:20
    imode shipping_mode
    """,label=_("Header")) # sales_remark

    general = dd.Panel("""
    invoice_header:60 totals:20
    ItemsByInvoice
    """,label=_("General"))

    more = dd.Panel("""
    id user language project
    intro
    """,label=_("More"))

    accounting = dd.Panel("""
    journal year number narration
    accounting.MovementsByVoucher
    """,label=_("Ledger"))

class Invoices(SalesDocuments):
    ...
    detail_layout = InvoiceDetail()
../_images/layouts2.jpg

layouts2.jpg

../_images/layouts3.jpg

layouts3.jpg

../_images/layouts4.jpg

layouts4.jpg

Layouts and polymorphism

lino_xl.lib.contacts uses MTI to represent the fact that a Partner can be either a Person or a Company. here are the three resulting detail windows.

class PartnerDetail(dd.FormLayout):

    main = """
    address_box:60 contact_box:30
    bottom_box
    """

    address_box = dd.Panel("""
    name_box
    country region city zip_code:10
    addr1
    street_prefix street:25 street_no street_box
    addr2
    """,label = _("Address"))

    contact_box = dd.Panel("""
    info_box
    email:40
    url
    phone
    gsm fax
    """,label = _("Contact"))

    bottom_box = """
    remarks
    is_person is_company #is_user
    """

    name_box = "name"
    info_box = "id language"
../_images/mti1.jpg

mti1.jpg

class PersonDetail(PartnerDetail):

    name_box = "last_name first_name:15 gender title:10"
    info_box = "id:5 language:10"
    bottom_box = "remarks contacts.RolesByPerson"
../_images/mti2.jpg

mti2.jpg

class CompanyDetail(PartnerDetail):

    bottom_box = """
    type vat_id:12
    remarks contacts.RolesByCompany
    """
../_images/mti3.jpg

mti3.jpg

TODO: continue this tutorial.