Where can I find a database relations map?

(Tryton 5.0)
I’m trying to find all fields I can access in a report, following data/table relations.
Do modules and Tryton have documentation about database structure and relations?

You can browse models from “Administration>Models”.

An example I don’t find in Administration-Models-Fields:
sale.payment_term.name

A relation like this one I had to explore trough SQL database tables, making test and error.

Where can I find a database relations map?

It is there. In the sale.sale model you can find the field payment_term which has as relation account.invoice.payment_term which has a name field.
It will be easier to browse if we showed a Many2One for the model relation instead of the name.

1 Like

Okay, i go to Administration-Models-Models and filter model name: sale.sale
I double-click the record to open detail and I see a Fields collection, where I find account.invoice.payment_term
But: How do I explore its collection with fields like the case “name” ?

In model ‘sale.sale’ (database: sale_sale), has a field called “payment_term”
which is “Many2One” field from model "account.invoice.payment_term"

or you may check on the the table “account_invoice_payment_term”,

1 Like

Thank you, but:
If I search “Model Name”: sale.sale
Target model records are not listed: account.invoice.payment_term
I’m trying to find a way to find other relations from (as this sale.sale example) any data object through whole available tree.

¿How can I explore or browse to walk from sale.sale to account.invoice… and find related items? (not only sale.sale but any model to compose reports)

I’ve tried sale.account.invoice.payment_term.line.delta.days and it complains with “object at 0x7f59524a7e10> has no member named “account”
Tried too with sale.payment_term.line.delta.days and got similar result (it has no member named “line”).

Thank you all, again.

What field in account_invoice are you looking for ?

Everyone.

Is there some published documentation about names and relations rules for writing report fields?

This all seems a litlle complicated for non Tryton developers, and I want to try to make reports opening database from another database GUI manager. This is another big reason to need a database relations map.

I think it is wrong to focus on database level. On tryton we have Function fields which do not exist on database but you can use them on reports as they are computed automatically by the system.

The only place to look for the fields to be used on reports (and views also) is to browse models:

I don’t care if Tryton software computes more calculated fields as an additional layer to database ones: I want to design reports without having to reach developer knowledge level.
This can be possible with a fields map with their relations easy to explore: Either through complete documentation or comprehensive “Models” explorer with field name-concatenation helper.

I am not sure if this will help you, but you can select a model in the GUI, and click on the Report Button to get a Graph.

But you need pydot installed on the server.

Also you could use “trytond/bin/trytond-console”, load models or records and find fields names. Use dir() to known more info.

Or Administration/Models menu.

tryton-console was introduced on 5.2 series