_sql_constraints = [
('date_order_required', "CHECK( (state IN ('完成') AND date_order IS NOT NULL) OR state NOT IN ('完成') )", "确认前日期必填."),
]
from dtcloud import api, exceptions, fields, models, _
@api.constrains('end_date', 'start_date')
def check_date(self):
for line in self:
if line.end_date < line.start_date:
raise exceptions.ValidationError("开始日其不能晚于结束日期!")