تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
5 الردود
10718 أدوات العرض

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

الصورة الرمزية
إهمال

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

أفضل إجابة

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,

            })

الصورة الرمزية
إهمال

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

أفضل إجابة

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


الصورة الرمزية
إهمال
أفضل إجابة

hello ,

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 19
6528
0
أبريل 23
2973
0
مايو 15
4480
2
مارس 15
3763
2
سبتمبر 24
2408