Skip to Content
मेन्यू
This question has been flagged
1 Reply
3310 Views

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
Discard
Best Answer
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
Discard
Related Posts Replies Views Activity
0
मार्च 21
3233
1
जुल॰ 25
2362
2
जुल॰ 25
7857
2
जुल॰ 25
4255
2
जुल॰ 25
4020