如何停止在ODOO 10中引发验证错误 例如,在project.py文件中,我想停止引发此验证错误:
@api.constrains('date_start', 'date_end')
def _check_dates(self):
if any(self.filtered(lambda task: task.date_start and task.date_end and task.date_start > task.date_end)):
raise ValidationError(_('Error ! Task starting date must be lower than its ending date.'))
答案 0 :(得分:1)
您可以通过覆盖该功能来禁用该警告。试试以下代码,
@api.constrains('date_start', 'date_end')
def _check_dates(self):
if any(self.filtered(lambda task: task.date_start and task.date_end and task.date_start > task.date_end)):
pass;
#raise ValidationError(_('Error ! Task starting date must be lower than its ending date.'))
希望它会对你有所帮助。