From ee5ca5c09afd924cbeac272467330b450e9b9267 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 24 Sep 2024 11:57:07 +0200 Subject: [PATCH] T1826 T1845 FIX division by zero --- crowdfunding_compassion/models/crowdfunding_participant.py | 2 +- crowdfunding_compassion/models/crowdfunding_project.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crowdfunding_compassion/models/crowdfunding_participant.py b/crowdfunding_compassion/models/crowdfunding_participant.py index 4b4d357..261668e 100644 --- a/crowdfunding_compassion/models/crowdfunding_participant.py +++ b/crowdfunding_compassion/models/crowdfunding_participant.py @@ -122,7 +122,7 @@ def _compute_product_number_reached(self): lambda line: line.payment_state == "paid" ) price_total = sum(invl.mapped("price_total")) - standard_price = participant.project_id.product_id.standard_price + standard_price = participant.project_id.product_id.standard_price or 1 participant.product_number_reached = round(price_total / standard_price) def _compute_sponsorships(self): diff --git a/crowdfunding_compassion/models/crowdfunding_project.py b/crowdfunding_compassion/models/crowdfunding_project.py index 4004ddd..cb0799d 100644 --- a/crowdfunding_compassion/models/crowdfunding_project.py +++ b/crowdfunding_compassion/models/crowdfunding_project.py @@ -301,7 +301,7 @@ def _compute_product_number_reached(self): price_total = results.get(project.id, 0) project.amount_reached = round(price_total) project.product_number_reached = round( - price_total / project.product_id.standard_price + price_total / (project.product_id.standard_price or 1) ) def _compute_number_sponsorships_goal(self):