Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
10732 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 19
6544
0
เม.ย. 23
2975
0
พ.ค. 15
4490
2
มี.ค. 15
3787
2
ก.ย. 24
2413