Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6168 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

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?

คำตอบที่ดีที่สุด

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 

อวตาร
ละทิ้ง
ผู้เขียน

Thank You

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 25
16170
3
เม.ย. 25
6743
1
มิ.ย. 25
25899
Compute Fields แก้ไขแล้ว
2
ก.ค. 24
8026
1
ม.ค. 24
2347