Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
5 Odgovori
10731 Prikazi

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Opusti

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

Best Answer

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
Opusti

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

Best Answer

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
Opusti
Best Answer

hello ,

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

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
sep. 19
6541
0
apr. 23
2975
0
maj 15
4489
2
mar. 15
3786
2
sep. 24
2413