diff --git a/my_compassion/controllers/my2_donations.py b/my_compassion/controllers/my2_donations.py index 1eb72363..b78e6a0a 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 or price <= 0: 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": diff --git a/my_compassion/models/product_template.py b/my_compassion/models/product_template.py index 80d0c7e4..11693d53 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): diff --git a/my_compassion/templates/components/my2_donation_form.xml b/my_compassion/templates/components/my2_donation_form.xml index a9cb7118..c8a11bc1 100644 --- a/my_compassion/templates/components/my2_donation_form.xml +++ b/my_compassion/templates/components/my2_donation_form.xml @@ -118,10 +118,7 @@ class="suggested-amount" />