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

I have this case:

class MyClass()

field1 = fields.Char()

field2 = fields.Selection([(1)(2)(3)])

field3 = fields.Integer()

field4 = fields.Integer()

field5 = fields.Integer()

field6 = fields.Integer()

@api.depends(field2)

def my fun(self):

for data in self:

if field2 =='option1':

field3 = 0

 ~ in view field4 gets an input (integer) and the form is saved and the these records go to database so far so good now comes my stuck when i try to create another record like this:

@api.depends

def my_another_fun(self):

for data in self:

if field2 == '(option2)':

field5 = field4 +1

At this point i don't know how to compute field5 based on the field4 stored valued

thanks in advance.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank u Mohammed Amal my code in @api.depends is syntactically like u suggested it was my mistake when posted, so i tried to edit it but didn't happen. The problem is that i can't compute based on a stored record.

Tác giả

I already have found what causes the issue. This seems to be simple but in terms of what i want to achieve it is complex. Thanks to all who read the post and most to Mohammed Amal for his kind answer.

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

You have'nt specified which field on depends 

try this :

@api.depends('field4')

def my_another_fun(self):

    for data in self:

        if field2 == '(option2)':

            field5 = field4 +1

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 24
12681
1
thg 10 17
11427
2
thg 7 25
4489
1
thg 6 25
15232
3
thg 4 25
5354