​
Hi Mauricio,
There are a few nettiquette rules to participate in mailing lists like this
one, please check it [1]​.
If you break those rules *over and over* you will likely not get the help
you need.
Specially learn to quote text and read what others are quoting you about
when they answer.

Also it's not well seen that you post so many images, many people won't see
them cause their
mailer doesn't handle them like gmail (not everyone uses gmail). Even gmail
shows them wider
than my screen which is very unpleasant.
Code, and errors can almost always be copy/pasted in text, and images
cannot be quoted to
answer your problem step by step.

Please follow me in between the lines below.

2017-04-26 14:21 GMT-03:00 Mauricio Martinez Garcia <[email protected]>:

>
> Sorry if my explanation is not clear.
>
>
> I will try explain more clear.
>
> First, i try to create a new model medica.accounting_services related
> with medica.accounting_services.line.
>
> on the first model (acounting_services) i try to asociate one field with
> the model (gnuhealth.patient) for get the information about the patient (or
> in the model case the employee)
>
> account_patient = fields.Many2One('gnuhealth.patient', 'Paciente')
>
> equally, i will asociate the same model with my servicesLine model
>
> account_services_line = fields.One2Many('medica.accounting_services.line',
>  'account_services_line', 'Servicios', help="Servicios")
>
>
Looks like the second parameter should be 'accountid' (I would just call it
'account' to follow tryton coding style).
​


> then, after that, i will relate the ServicesLine with these models:
> ​​
> accountid = fields.Many2One('medica.accounting_services', 'accountid',
> readonly=True)
>

Again, I would just call this field 'account'. (It is true that the
database just saved the id,
but internally to tryton, you get the whole structure. You would access the
id by
using 'account.id' and the patient by using account.account_patient.
Notice also the redundance of the 'account_patient' field name (like the
others).
If the field is on the account model, you already know it's the account's
patient,
so just patient would be enough, then refer to it from the service lines
with
'self.account.patient'

Also, in this case the second parameter is just a string (the label of the
field)


> I need asociate these fields to the model product.product (is part of the
> tryton base i checked this information on this URL
> http://doc.tryton.org/3.0/modules)
>
> services_concept = fields.Char('services_concept') #get the Description
> product
>

​In this case the parameter is a string (for a label)​

​I don't understand the comment​, because you are not getting it from
anywhere, a Char field is for the user to type it in.

services_product = fields.Many2One('product.product','code') #get the
> product code
>

Second parameter is just a string for the label.

i need asociate these fields to the mode.template model, that equally is
> part of the tryton modules.
>
> services_description = fields.Many2One('product.template','name')
>

​Again the second parameter is just a string for the label.
I don't understand why you assume this is a name, this is a relationship
with the 'product.template' model.

Also I don't see why you need both relationships, product.product and
product.template.
Usually you just need to relate to product.product​ and this will give you
access
to all the fields in product.product.

If you really need it you can define a field.Function which calls a
function that returns the name of the
services_product (so services_product.name).
But usually this is not needed unless the calculation is more complicate.
When you show the service_product on the screen, it will show up by it's
name anyway.
And from a ServiceLine instance you can alwas access
self.service_product.name


> At the end, i see these "models" as one data structure that i need
> document in a schema. In my particular case, i do it with one datamodel.
> (sorry i'm old school)
> But, finally, the tryton's models  are database models.
>

​Yes, but if you think about it
e​xactly like a database you will build up your relationships wrong.
In tryton you relate once to the model and then you get access all it's
fields through this relationship.
No need to relate to each and every field of the model, this would be wrong​
​.​


​If you are having a hard time understanding tryton internals versus your
database knowledge
I would advice you to follow some simple tutorial [2] and check the
database's structure
every time you make a change on the code.


I see this of this form:
>
> then, if I don't need create the foreing key for the relation, i want to
> know how to relate tryton the models internally to get the information of
> the other model.
>
> i created the enterprise module and individual module of my code ignoring
> my FK | PK fields, but doesn't work, i receive the errors:
>
​

>
> in english is "the relation doesn't exist" 
> medica_accounting_entpservices_id_seq,
> this show me that tryton is not creating automatically the relation.
> due than this, i try understanding how tryton make to relate the models.
>

I wonder:
Did you update the database?
Did you define your views (in xml) correctly?
It looks weird because the error stays the same though it looks like you
changed your model's names.


​I hope I help you clarify some​.
Cheers,
Karla.
​PS: I don't feel comfortable telling you all the rules, but I try to
explain as kindly as possible.
PS2: using LANG=C to get the error in english is just a matter of kindness
(plus it helps other people searching your same error)

​[1] http://groups.tryton.org/netiquette
[2] http://hg.tryton.org/training (instructions show up here
http://hg.tryton.org/)

-- 
-------------------------
Karla  Mª  Stenger  Sábat
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/CAF9qxNrt5vnzy2igesLXh%2B17OeyWtTWRgGWyiSjjWRjT8E2xMQ%40mail.gmail.com.

Reply via email to