Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5 Ответы
10720 Представления

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
6531
0
апр. 23
2973
0
мая 15
4481
2
мар. 15
3766
2
сент. 24
2408