From 36eefe07a7d8b163ec2df8d82ad7b8674dbdfc86 Mon Sep 17 00:00:00 2001 From: SlWa99 Date: Tue, 30 Dec 2025 15:50:54 +0100 Subject: [PATCH 1/6] [T2845] FIX: Change donation suggestions from quantity to amount --- my_compassion/models/product_template.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/my_compassion/models/product_template.py b/my_compassion/models/product_template.py index 80d0c7e4..0b87b73e 100644 --- a/my_compassion/models/product_template.py +++ b/my_compassion/models/product_template.py @@ -101,16 +101,25 @@ class ProductTemplate(models.Model): ) # Donation suggestions - my_compassion_donation_quantity_low = fields.Integer( - default=1, help="Lowest quantity suggestion when making a donation" + my_compassion_donation_amount_low = fields.Monetary( + string="Lowest Amount", + currency_field='currency_id', + default=15.0, + help="Lowest price suggestion when making a donation" ) - my_compassion_donation_quantity_medium = fields.Integer( - default=3, help="Medium quantity suggestion when making a donation" + my_compassion_donation_amount_medium = fields.Monetary( + string="Medium Amount", + currency_field='currency_id', + default=50.0, + help="Medium price suggestion when making a donation" ) - my_compassion_donation_quantity_high = fields.Integer( - default=5, help="Highest quantity suggestion when making a donation" + my_compassion_donation_amount_high = fields.Monetary( + string="Highest Amount", + currency_field='currency_id', + default=100.0, + help="Highest price suggestion when making a donation" ) def get_donation_limits(self, company, partner, sponsorship_id=None): From e63f9b45b46ea6ab5c42c1f4cd3f9e51f66e2081 Mon Sep 17 00:00:00 2001 From: SlWa99 Date: Tue, 30 Dec 2025 15:52:17 +0100 Subject: [PATCH 2/6] [T2845] FIX: Update donation price logic to use direct amounts --- my_compassion/controllers/my2_donations.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/my_compassion/controllers/my2_donations.py b/my_compassion/controllers/my2_donations.py index 1eb72363..8131091a 100644 --- a/my_compassion/controllers/my2_donations.py +++ b/my_compassion/controllers/my2_donations.py @@ -323,8 +323,8 @@ def my2_gifts_thank_you_page(self, **kwargs): def _extract_donation_order_line_fields(product_template, post): # Compute quantity price = 0 - amount = post.get("suggested_amount") - if amount == "custom": + amount_type = post.get("suggested_amount") + if amount_type == "custom": try: price = float(post.get("custom_amount")) except (ValueError, TypeError) as e: @@ -333,15 +333,15 @@ def _extract_donation_order_line_fields(product_template, post): if price <= 0: raise BadRequest() else: - quantities = { - "low": product_template.my_compassion_donation_quantity_low, - "medium": product_template.my_compassion_donation_quantity_medium, - "high": product_template.my_compassion_donation_quantity_high, + amounts = { + "low": product_template.my_compassion_donation_amount_low, + "medium": product_template.my_compassion_donation_amount_medium, + "high": product_template.my_compassion_donation_amount_high, } - quantity = quantities.get(amount) - if not quantity: + price = amounts.get(amount_type) + + if price is None: raise BadRequest() - price = quantity * product_template.list_price # Get frequency frequency = post.get("frequency") @@ -350,6 +350,7 @@ def _extract_donation_order_line_fields(product_template, post): order_line_fields = { "product_id": product.id, "price_unit": price, + "product_uom_qty": 1.0, "frequency": frequency, } if product_template.my_compassion_donation_type == "gift": From 7bd1b7f2ed0bd76040d7afe8c0b657dea9e4c38b Mon Sep 17 00:00:00 2001 From: SlWa99 Date: Tue, 30 Dec 2025 15:53:31 +0100 Subject: [PATCH 3/6] Update backecnd fields to display donation amounts --- my_compassion/views/product_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/my_compassion/views/product_view.xml b/my_compassion/views/product_view.xml index 17fb26ed..01e0a620 100644 --- a/my_compassion/views/product_view.xml +++ b/my_compassion/views/product_view.xml @@ -101,9 +101,9 @@ string="Suggested Donations" attrs="{'invisible': [('activate_for_my_compassion', '=', False)]}" > - - - + + + From dd792f298add52a9726de826e3cd83a50025280d Mon Sep 17 00:00:00 2001 From: SlWa99 Date: Tue, 30 Dec 2025 15:54:14 +0100 Subject: [PATCH 4/6] [T2845] FIX: Display direct amounts and remove price multipication --- my_compassion/templates/components/my2_donation_form.xml | 6 +++--- my_compassion/templates/components/my2_donation_product.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/my_compassion/templates/components/my2_donation_form.xml b/my_compassion/templates/components/my2_donation_form.xml index a9cb7118..b7824b21 100644 --- a/my_compassion/templates/components/my2_donation_form.xml +++ b/my_compassion/templates/components/my2_donation_form.xml @@ -120,7 +120,7 @@