forked from Yaltik/golem
[IMP]GOLEM Resource Timetable : usage of default values for time_start/stop on contraint + requirement only on client side
This commit is contained in:
parent
398a3e7f63
commit
da00acea29
@ -46,16 +46,7 @@ class GolemTimetable(models.Model):
|
|||||||
""" fill time_start et time_stop if availibility_24 is True """
|
""" fill time_start et time_stop if availibility_24 is True """
|
||||||
for line in self:
|
for line in self:
|
||||||
if line.availibility_24:
|
if line.availibility_24:
|
||||||
line.time_start = 0.0
|
line.update({'time_start': 0.0, 'time_stop': 23.98})
|
||||||
line.time_stop = 23.98
|
|
||||||
@api.constrains('availibility_24')
|
|
||||||
@api.multi
|
|
||||||
def check_time_filling(self):
|
|
||||||
""" Check start and stop time filling out"""
|
|
||||||
for line in self:
|
|
||||||
if not line.availibility_24 and (not line.time_start or not line.time_stop):
|
|
||||||
raise ValidationError(_('Start and stop time should be filled out '
|
|
||||||
'if the 24 availibility is not checked.'))
|
|
||||||
|
|
||||||
@api.onchange('time_start')
|
@api.onchange('time_start')
|
||||||
def onchange_time_start(self):
|
def onchange_time_start(self):
|
||||||
@ -64,11 +55,18 @@ class GolemTimetable(models.Model):
|
|||||||
if line.time_start and not line.time_stop:
|
if line.time_start and not line.time_stop:
|
||||||
line.time_stop = line.time_start + 1
|
line.time_stop = line.time_start + 1
|
||||||
|
|
||||||
|
@api.constrains('availibility_24')
|
||||||
|
def check_avaibility24(self):
|
||||||
|
""" Checks hour consistency against avaibility 24 """
|
||||||
|
for line in self:
|
||||||
|
if line.availibility_24:
|
||||||
|
line.write({'time_start': 0.0, 'time_stop': 23.98})
|
||||||
|
|
||||||
@api.constrains('time_start', 'time_stop')
|
@api.constrains('time_start', 'time_stop')
|
||||||
def _check_time_consistency(self):
|
def _check_time_consistency(self):
|
||||||
""" Checks time consistency """
|
""" Checks time consistency """
|
||||||
for timetable in self:
|
for line in self:
|
||||||
if timetable.time_stop <= timetable.time_start:
|
if line.time_stop <= line.time_start:
|
||||||
raise ValidationError(_('End time should be after than start time'))
|
raise ValidationError(_('End time should be after than start time'))
|
||||||
|
|
||||||
@api.constrains('time_start', 'time_stop')
|
@api.constrains('time_start', 'time_stop')
|
||||||
|
@ -28,9 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="weekday" />
|
<field name="weekday" />
|
||||||
<field name="availibility_24"/>
|
<field name="availibility_24"/>
|
||||||
<field name="time_start" string="Start hour" widget="float_time"
|
<field name="time_start" string="Start hour" widget="float_time"
|
||||||
attrs="{'required' : [('availibility_24', '=', False)]}"/>
|
required="1" />
|
||||||
<field name="time_stop" string="Stop hour" widget="float_time"
|
<field name="time_stop" string="Stop hour" widget="float_time"
|
||||||
attrs="{'required' : [('availibility_24', '=', False)]}"/>
|
required="1" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user