forked from Yaltik/golem
[TMP] check date and check date in constrains and raise validation error
This commit is contained in:
parent
0841d1de36
commit
5442ab5af3
@ -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.'))
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user