From 87e5de7918acd5e309c5c8b6bc2206e6bf1a7ea5 Mon Sep 17 00:00:00 2001 From: Benjamin <35699580+benj-filament@users.noreply.github.com> Date: Mon, 17 Jun 2019 13:46:14 +0200 Subject: [PATCH] fix bug division by 0 --- models/training_training.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/training_training.py b/models/training_training.py index ef46c22..dca823f 100644 --- a/models/training_training.py +++ b/models/training_training.py @@ -109,8 +109,10 @@ class Training(models.Model): @api.depends('student_ids', 'cost') def _compute_costs(self): - self.student_cost = self.cost / self.students_count - self.rate = self.cost / self.hours_total + if self.students_count > 0: + self.student_cost = self.cost / self.students_count + if self.hours_total > 0: + self.rate = self.cost / self.hours_total @api.depends('session_ids') def _compute_sessions(self): -- GitLab