Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
6191 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Auteur

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?

Beste antwoord

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
Annuleer
Auteur

Thank You

Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 25
16198
3
apr. 25
6782
1
jun. 25
25919
2
jul. 24
8117
1
jan. 24
2355