跳至內容
選單
此問題已被標幟
2 回覆
6179 瀏覽次數

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

相關帖文 回覆 瀏覽次數 活動
1
6月 25
16179
3
4月 25
6759
1
6月 25
25904
2
7月 24
8057
1
1月 24
2350