تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2806 أدوات العرض

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'

الصورة الرمزية
إهمال
أفضل إجابة
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.!!


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 21
3146
1
يوليو 25
2211
2
يوليو 25
7706
2
يوليو 25
4125
2
يوليو 25
3877