Skip to Content
Menu
This question has been flagged
1 Atsakyti
4172 Rodiniai

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'

Portretas
Atmesti
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.!!


Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
kov. 21
3252
1
liep. 25
2511
2
liep. 25
7955
2
liep. 25
4395
2
liep. 25
4104