跳至內容
選單
此問題已被標幟
5 回覆
10721 瀏覽次數

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
9月 19
6533
0
4月 23
2973
0
5月 15
4481
2
3月 15
3771
2
9月 24
2408