Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
4731 Zobrazení

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
Zrušit
Nejlepší odpověď
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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
bře 21
3301
3
zář 25
2654
0
srp 25
205
1
srp 25
2167
2
čvc 25
8065