solve hours validation for import record in timesheet
This commit is contained in:
parent
b221e126dc
commit
ad5d715e4e
|
@ -169,11 +169,6 @@ class AccountAnalyticLine(models.Model):
|
|||
raise ValidationError(_("End time cannot be earlier than Start time"))
|
||||
self.unit_amount = res"""
|
||||
|
||||
@api.onchange('start_datetime', 'end_datetime')
|
||||
def _onchange_start_end_date_time(self):
|
||||
if self.start_datetime and self.end_datetime:
|
||||
total_hours = (self.end_datetime - self.start_datetime).total_seconds() / 3600
|
||||
self.unit_amount = total_hours
|
||||
|
||||
# @api.onchange('start_time', 'end_time')
|
||||
# def _onchange_start_end_time(self):
|
||||
|
@ -234,6 +229,12 @@ class AccountAnalyticLine(models.Model):
|
|||
# res['datas'][index][durationindex] = duration_time
|
||||
return res
|
||||
|
||||
@api.onchange('start_datetime', 'end_datetime')
|
||||
def _onchange_start_end_date_time(self):
|
||||
if self.start_datetime and self.end_datetime:
|
||||
total_hours = (self.end_datetime - self.start_datetime).total_seconds() / 3600
|
||||
self.unit_amount = total_hours
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
# if vals.get('unit_amount') == 0.0:
|
||||
|
@ -245,6 +246,10 @@ class AccountAnalyticLine(models.Model):
|
|||
value.project_id._onchange_calculate_timesheet_hours()
|
||||
value.project_id._compute_calc()
|
||||
value._onchange_start_end_date_time()
|
||||
if value.unit_amount == 0.0:
|
||||
raise ValidationError(_("Your can not fill 0.0 hour entry"))
|
||||
if value.unit_amount >= 24.0:
|
||||
raise ValidationError(_("Your can not fill more than 24.0 hour entry"))
|
||||
return value
|
||||
|
||||
def write(self, vals):
|
||||
|
|
Loading…
Reference in New Issue