[TMP] check date and check date in constrains and raise validation error

This commit is contained in:
michel 2018-01-16 17:08:15 +01:00
parent 0841d1de36
commit 5442ab5af3
2 changed files with 11 additions and 2 deletions

View File

@ -54,6 +54,13 @@ class GolemSeason(models.Model):
""" Check if end date if after start date and if there is no conflict
with existing periods """
for season in self:
if season.date_start:
if not season.date_end:
raise models.ValidationError(_('The date end is required'))
if season.date_end:
if not season.date_start:
raise models.ValidationError(_('The date start is required'))
if season.date_start > season.date_end:
raise models.ValidationError(_('Start of the period cannot be '
'after end of the period.'))

View File

@ -37,8 +37,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="is_default" invisible="True" />
<field name="membership_id" options="{'no_create': true}"/>
<field name="name" />
<field name="date_start" />
<field name="date_end" />
<field name="date_start"
attrs="{'required': [('date_end', '!=', False)]}" />
<field name="date_end"
attrs="{'required': [('date_start', '!=', False)]}" />
</group>
</sheet>
</form>