Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2869 Weergaven

Hello,

i create ValidationError show up when button clicked and the condition of field is empty. But when i try to test it with field is filled the validationerror still showing up. What's wrong with my code ?


def action_approved(self):
for rec in self:
expense_account = self.env['account.pettycash.voucher.wizard.line'].search([('expense_account','=',False)])
if expense_account :
raise ValidationError('Fill the expense account!')
else :
rec.state = 'approved'

Avatar
Annuleer
Beste antwoord
Try Bellow code:-
def action_approved(self):    
    expense_account = False
    expense_account = self.env['account.pettycash.voucher.wizard.line'].search([('expense_account','=',False)])
for rec in self:
if expense_account :
raise ValidationError('Fill the expense account!')
else :
rec.state = 'approved'

Thanks.!!


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 21
3188
1
jul. 25
2266
2
jul. 25
7746
2
jul. 25
4166
2
jul. 25
3943