콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
10823 화면

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
6593
0
4월 23
3052
0
5월 15
4575
2
3월 15
3873
2
9월 24
2569