Discussion:
[tryton] relations
Cato Nano
2018-01-16 10:02:29 UTC
Permalink
I have 2 models, with a relation between them

Much like Sales and SaleLine

Let' s say I have Bolletta and BollettaLine

Some BollettaLine fields are calcolated and they depend on some Bolletta fields

How do I do that ?

Also, I' d like to show on the BollettaLine form view some Bolletta fields

I tried this

SomeBollettaField = fields.Many2One('tributi.bolletta', 'Some Bolletta Field')

but when I update the module, I get

psycopg2.ProgrammingError: ERRORE: non Ú possibile implementare il vincolo di chiave esterna "tributi_affissione_dataCommissione_fkey"
DETAIL: Le colonne chiave "dataCommissione" e "id" hanno tipi incompatibili: date e integer.

Translated:

ERROR: The foreign key constarint tributi_affissione_dataCommissione_fkey can't be implemented
DETAIL: The key columns "SomeBollettaField" and "id" have mismatching types: date and integer
--
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/f803c9f8-c3df-4123-8a4f-4ca5d0744d51%40googlegroups.com.
Cato Nano
2018-01-16 10:09:15 UTC
Permalink
Post by Cato Nano
I have 2 models, with a relation between them
Much like Sales and SaleLine
Let' s say I have Bolletta and BollettaLine
Some BollettaLine fields are calcolated and they depend on some Bolletta fields
How do I do that ?
Also, I' d like to show on the BollettaLine form view some Bolletta fields
I tried this
SomeBollettaField = fields.Many2One('tributi.bolletta', 'Some Bolletta Field')
but when I update the module, I get
psycopg2.ProgrammingError: ERRORE: non Ú possibile implementare il vincolo di chiave esterna "tributi_affissione_dataCommissione_fkey"
DETAIL: Le colonne chiave "dataCommissione" e "id" hanno tipi incompatibili: date e integer.
ERROR: The foreign key constarint tributi_affissione_dataCommissione_fkey can't be implemented
DETAIL: The key columns "SomeBollettaField" and "id" have mismatching types: date and integer
ah the field has to be different

I think I made it
--
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/8828451f-b451-41b6-8d39-d29969834efe%40googlegroups.com.
Cato Nano
2018-01-16 10:15:25 UTC
Permalink
Post by Cato Nano
ah the field has to be different
I think I made it
No I didn' t make it

On the client I see a key error

here it is
https://imgur.com/a/Cwct2

This is how I defined my field

bollettaDataCommissione = fields.Many2One('tributi.bolletta', 'bolletta.dataCommissione')

I guess you could read it as

SomeBollettaField = fields.Many2One('tributi.bolletta', 'bolletta.bollettaField')
--
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/51d4877c-3dc0-4828-aab8-68a288e804c2%40googlegroups.com.
Sergi Almacellas Abellana
2018-01-16 10:40:44 UTC
Permalink
Post by Cato Nano
I have 2 models, with a relation between them
Much like Sales and SaleLine
Let' s say I have Bolletta and BollettaLine
Some BollettaLine fields are calcolated and they depend on some Bolletta fields
How do I do that ?
Also, I' d like to show on the BollettaLine form view some Bolletta fields
I tried this
SomeBollettaField = fields.Many2One('tributi.bolletta', 'Some Bolletta Field')
You have to create a function fields which is updated via
on_change_with. For example the product_uom_category [1]on the sale
lines uses the value from the product relation.

[1] http://hg.tryton.org/modules/sale/file/3414b8d97403/sale.py#l1057
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
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/3ca994d0-c373-8282-e666-b9186cab329f%40koolpi.com.
Cato Nano
2018-01-17 06:55:22 UTC
Permalink
Il giorno martedì 16 gennaio 2018 11:40:47 UTC+1, Sergi Almacellas Abellana ha
Post by Sergi Almacellas Abellana
You have to create a function fields which is updated via
on_change_with. For example the product_uom_category [1]on the sale
lines uses the value from the product relation.
[1] http://hg.tryton.org/modules/sale/file/3414b8d97403/sale.py#l1057
--
Thank you Sergi

This is the situation:

bollettaDataCommissione = fields.Function(fields.Many2One('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')

@fields.depends('bolletta')
def on_change_with_bollettaDataCommissione(self, name=None):
if self.bolletta:
return self.bolletta.dataCommissione


and I get

can't compare datetime.date to int
--
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/5c0dbd6d-78dc-4627-a580-8f78968a1e4c%40googlegroups.com.
Cato Nano
2018-01-17 06:57:29 UTC
Permalink
Post by Cato Nano
Il giorno martedì 16 gennaio 2018 11:40:47 UTC+1, Sergi Almacellas Abellana ha
Post by Sergi Almacellas Abellana
You have to create a function fields which is updated via
on_change_with. For example the product_uom_category [1]on the sale
lines uses the value from the product relation.
[1] http://hg.tryton.org/modules/sale/file/3414b8d97403/sale.py#l1057
--
Thank you Sergi
bollettaDataCommissione = fields.Function(fields.Many2One('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')
@fields.depends('bolletta')
return self.bolletta.dataCommissione
and I get
can't compare datetime.date to int
This is on BollettaLine, of course
--
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/3159f5c7-4b91-4e3e-ac73-35897b42a5c1%40googlegroups.com.
Cato Nano
2018-01-17 07:20:45 UTC
Permalink
Post by Cato Nano
Post by Cato Nano
Il giorno martedì 16 gennaio 2018 11:40:47 UTC+1, Sergi Almacellas Abellana ha
Post by Sergi Almacellas Abellana
You have to create a function fields which is updated via
on_change_with. For example the product_uom_category [1]on the sale
lines uses the value from the product relation.
[1] http://hg.tryton.org/modules/sale/file/3414b8d97403/sale.py#l1057
--
Thank you Sergi
bollettaDataCommissione = fields.Function(fields.Many2One('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')
@fields.depends('bolletta')
return self.bolletta.dataCommissione
and I get
can't compare datetime.date to int
This is on BollettaLine, of course
Aaah it' s like this

bollettaDataCommissione = fields.Function(fields.Date('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')

@fields.depends('bolletta')
def on_change_with_bollettaDataCommissione(self, name=None):
if self.bolletta:
return self.bolletta.dataCommissione
--
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/a1fa92ad-62ff-4902-b3e8-9a22db2d6e92%40googlegroups.com.
Cato Nano
2018-01-17 07:51:35 UTC
Permalink
Post by Cato Nano
Aaah it' s like this
bollettaDataCommissione = fields.Function(fields.Date('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')
@fields.depends('bolletta')
return self.bolletta.dataCommissione
The date field works, but where' s my label ?

The field name is shown instead of the field string, as you can see here

https://imgur.com/a/tu5fL
--
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/f14765de-d2e4-4376-987e-83aa996f93e1%40googlegroups.com.
Sergi Almacellas Abellana
2018-01-17 08:32:08 UTC
Permalink
Post by Cato Nano
Post by Cato Nano
Aaah it' s like this
bollettaDataCommissione = fields.Function(fields.Date('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')
@fields.depends('bolletta')
return self.bolletta.dataCommissione
The date field works, but where' s my label ?
The label used is the string of the target field. In a date field, this
is the first argument. In your case is 'tributi.bolleta'. You should
update the field definition to show the correct label.
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
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/5c7220b3-48a1-cd9b-6f7e-5990235279a2%40koolpi.com.
Cato Nano
2018-01-21 09:30:17 UTC
Permalink
Post by Sergi Almacellas Abellana
Post by Cato Nano
Post by Cato Nano
Aaah it' s like this
bollettaDataCommissione = fields.Function(fields.Date('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')
@fields.depends('bolletta')
return self.bolletta.dataCommissione
The date field works, but where' s my label ?
The label used is the string of the target field. In a date field, this
is the first argument. In your case is 'tributi.bolleta'. You should
update the field definition to show the correct label.
Thank you Sergi
I' ll try and report back
--
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/496c5637-fe37-42d4-801d-6c4235b9c4ca%40googlegroups.com.
Cato Nano
2018-01-23 16:52:44 UTC
Permalink
Post by Cato Nano
Post by Sergi Almacellas Abellana
Post by Cato Nano
Post by Cato Nano
Aaah it' s like this
bollettaDataCommissione = fields.Function(fields.Date('tributi.bolletta', 'Data di Commissione'), 'on_change_with_bollettaDataCommissione')
@fields.depends('bolletta')
return self.bolletta.dataCommissione
The date field works, but where' s my label ?
The label used is the string of the target field. In a date field, this
is the first argument. In your case is 'tributi.bolleta'. You should
update the field definition to show the correct label.
Thank you Sergi
I' ll try and report back
I tried and it works

Thanks
--
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/43325360-08de-4e47-92f2-de3e70e9d319%40googlegroups.com.
Loading...