Se rendre au contenu
Menu
Cette question a été signalée
5 Réponses
10714 Vues

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Ignorer

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

Meilleure réponse

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
Ignorer

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

Meilleure réponse

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
Ignorer
Meilleure réponse

hello ,

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

Avatar
Ignorer
Publications associées Réponses Vues Activité
1
sept. 19
6524
0
avr. 23
2973
0
mai 15
4479
2
mars 15
3761
2
sept. 24
2408