Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
5 Risposte
10730 Visualizzazioni

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Abbandona

Exactly as you did. You can now apply the sum (one + two) to a variable which is shown in the frontend.

Risposta migliore

try this one.

one = fields.Float()

two = fields.Float()

total = fields.Float(compute='_get_sum')


    @api.depends('one', 'two')

    def _get_sum(self):

        for rec in self:

           rec.update({

                'total': rec.one+rec.two,

            })

Avatar
Abbandona

sjmple and to the point:) My father nabaged to add field using your advice (he is non IT 60+). Thanks

Risposta migliore

Tested in Odoo v11

one = fields.Float()

two = fields.Float()

total = fields.Float(compute='_get_sum')


    @api.depends('one', 'two')

    def _get_sum(self):

        for rec in self:

          rec.total = rec.one+rec.two


Avatar
Abbandona
Risposta migliore

hello ,

you can add new field as compute field, and that new field make the total of field1 and field2.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
set 19
6540
0
apr 23
2975
0
mag 15
4488
2
mar 15
3786
2
set 24
2411