Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
10739 Lượt xem

Hello, 

i have two fields 

        one = fields.Float()

        two = fields.Float()

i want

toto = one + two 

how can i do that??

ODOO 11

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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,

            })

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

hello ,

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 19
6546
0
thg 4 23
2979
0
thg 5 15
4493
2
thg 3 15
3796
2
thg 9 24
2419