Skip to Content
Menu
This question has been flagged
5 Replies
10766 Rodiniai

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Portretas
Atmesti

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,

            })

Portretas
Atmesti

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


Portretas
Atmesti
Best Answer

hello ,

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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
rugs. 19
6568
0
bal. 23
2999
0
geg. 15
4510
2
kov. 15
3820
2
rugs. 24
2458