Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
6181 Visualizzazioni

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

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Autore

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?

Risposta migliore

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 

Avatar
Abbandona
Autore

Thank You

Post correlati Risposte Visualizzazioni Attività
1
giu 25
16181
3
apr 25
6760
1
giu 25
25904
2
lug 24
8070
1
gen 24
2351