On 2018-01-10 09:03, Cato Nano wrote:
> I have these 2 fields
> 
>     numeroGiorni = fields.Function(fields.Integer('Numero 
> Giorni'),'on_change_with_numeroGiorni')
>     @fields.depends('dataInizio', 'dataFine')
>     def on_change_with_numeroGiorni(self, name=None):
>         if self.dataInizio and self.dataFine:
>             return abs((self.dataFine - self.dataInizio).days) + 1
>         return 0
> 
> [...]
> 
>     fattoreGiorni = fields.Function(fields.Numeric('fattoreGiorni'), 
> 'on_change_with_fattoreGiorni')
> 
>     @fields.depends('numeroGiorni')
>     def on_change_with_fattoreGiorni(self, name=None):
>         return (self.numeroGiorni - 10) / 5
> 
> 
> fattoreGiorni DOESN'T get assigned
> I can't see why

It is difficult to answer without having more information about the
scenario you are following.

But already there are some potential issues like using the value of a
field without checking if it is not 'None'.
Also be aware that Function fields does not trigger other on_change*,
indeed you must make the other one depending on the first one. It should
look like that:

    @fields.depends(methods='numeroGiorni')
    def on_change_with_fattoreGiorni(self, name=None):
        numeroGiorni = self.on_change_with_numeroGiorni()
        return (numeroGiorni - 10) / 5

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
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/20180112224446.GE4227%40kei.

Reply via email to