Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
5 Antworten
10744 Ansichten

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Avatar
Verwerfen

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

Beste Antwort

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
Verwerfen

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

Beste Antwort

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
Verwerfen
Beste Antwort

hello ,

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

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Sept. 19
6549
0
Apr. 23
2982
0
Mai 15
4497
2
März 15
3800
2
Sept. 24
2423