Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
5 Odpovědi
10762 Zobrazení

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Zrušit

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

Nejlepší odpověď

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
Zrušit

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

Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

hello ,

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
zář 19
6566
0
dub 23
2995
0
kvě 15
4508
2
bře 15
3816
2
zář 24
2445