Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
5 Vastaukset
10742 Näkymät

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Hylkää

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

Paras vastaus

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
Hylkää

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

Paras vastaus

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
Hylkää
Paras vastaus

hello ,

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

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
syysk. 19
6548
0
huhtik. 23
2981
0
toukok. 15
4494
2
maalisk. 15
3797
2
syysk. 24
2419