Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5 Antwoorden
10719 Weergaven

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Annuleer

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

Beste antwoord

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
Annuleer

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

Beste antwoord

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
Annuleer
Beste antwoord

hello ,

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
sep. 19
6531
0
apr. 23
2973
0
mei 15
4481
2
mrt. 15
3765
2
sep. 24
2408