summaryrefslogtreecommitdiff
path: root/addons/resource/models
diff options
context:
space:
mode:
authorSwapnesh Shah <swapneshshah111@gmail.com>2018-12-19 17:30:41 +0000
committerGitHub <noreply@github.com>2018-12-19 17:30:41 +0000
commit6ead395271ed80f5e47ed3de04bafa5968d2100b (patch)
tree6f4e47fe2c02e18eb379cd5a470ac1a57ade5c27 /addons/resource/models
parentd8eb0f2555981df0729e46d06b1523e3c34b0b9b (diff)
[FIX] resource: Prevent zero division error
closes odoo/odoo#29656
Diffstat (limited to 'addons/resource/models')
-rw-r--r--addons/resource/models/resource.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/resource/models/resource.py b/addons/resource/models/resource.py
index 08d6b9e73e9..7c4b55e3ae2 100644
--- a/addons/resource/models/resource.py
+++ b/addons/resource/models/resource.py
@@ -192,7 +192,8 @@ class ResourceCalendar(models.Model):
hour_count = 0.0
for attendance in attendances:
hour_count += attendance.hour_to - attendance.hour_from
- self.hours_per_day = float_round(hour_count / float(len(set(attendances.mapped('dayofweek')))), precision_digits=2)
+ if attendances:
+ self.hours_per_day = float_round(hour_count / float(len(set(attendances.mapped('dayofweek')))), precision_digits=2)
# --------------------------------------------------
# Computation API