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

Hello!

I'm trying make button which will change 'stage_id' in Recruitment form view.

Code:

def CONTINUE_TO_NEXT_STEP_FUNCTION_1(self):
        if self.stage_id.sequence == 2:
            return self.write({'stage_id'3})
        elif self.stage_id.sequence == 3:
            return self.write({'stage_id'4})
        elif self.stage_id.sequence == 4:
            return self.write({'stage_id'5})
        else:
            raise ValidationError("Error. Contact the administrator.")

And this code works if I create new database and use button in new DB. But in my original DB in 2 stage_id I getting ValidationError. And in 3 stage nothing happens when I push the button.

I suspect I’ve used the wrong syntax. Can you tell me the best way to proceed?

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

self.stage_id has an 'id' besides 'sequense'

I managed to make it work on all databases using this code:

def CONTINUE_TO_NEXT_STEP_FUNCTION_1(self):
if self.stage_id.id == 2:
return self.write({'stage_id': 3})
if self.stage_id.id == 3:
return self.write({'stage_id': 4})
elif self.stage_id.id == 4:
return self.write({'stage_id': 5})
else:
raise ValidationError("Error. Contact the administrator.")
الصورة الرمزية
إهمال
أفضل إجابة

try this 

if self.stage_id.sequence == 2 or self.stage_id.sequence == '2':

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مارس 24
2179
2
مارس 23
3756
2
أغسطس 22
3025
0
يونيو 21
2871
0
أبريل 25
1444