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

Hi, 

In payment model, i want the field amount to be computed only if it's a cash payment

i have a selection field called "receive type" whiche define if it's a cash payment or check or visa

is this possible? and if so, can i get some guidelines please 

 Thank you

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

hi 

you can write something like:

receive_type = fields.Selection([('cash', 'cash'),('visa', 'visa'),('check', 'check')])

amount = fields.Float( string = 'amount')

@api.onchange('receive_type')

def Onchange_receive_type(self):

for  rec in self:


if rec.receive_type == 'cash' :


rec.amount = your amount

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

Thank, that's work but the problem that cash is the default receive type and amount doesn't change till i change receive type, any suggestion?

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

Hello,

You can easy to get this value using onchange method because you can easy to update. even if you try to compute method in that case your field readonly tand i think that is wrong for in case of other payment options 

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

Thank You

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
16166
3
thg 4 25
6736
1
thg 6 25
25894
Compute Fields Đã xử lý
2
thg 7 24
8001
1
thg 1 24
2346