Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] sale_loyalty : Don't show discounts that are already claimed #173555

Conversation

yoba-odoo
Copy link
Contributor

Steps to reproduce:

- Install eCommerce and Loyalty module
- Create a Discount that is applied using code
- Generate coupon codes
- Modify the balance of the codes to be more than 1
- Go to website and create an order
- Proceed to checkout and apply one of the codes

Current behavior before PR:

The reward will be shown as claimable even after we already applied its code. This will lead that the user can be able to claim it more than once in the same order. This is happening becuase when getting the claimable rewards we are fetching the rewards that already got applied. https://github.com/odoo/odoo/blob/16.0/addons/sale_loyalty/models/sale_order.py#L655

Desired behavior after PR is merged:

We are excluding the already-applied coupons on the order to avoid using them more than once in the same order.

opw-4018909

@robodoo
Copy link
Contributor

robodoo commented Jul 17, 2024

Pull request status dashboard

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jul 17, 2024
Copy link
Contributor

@nle-odoo nle-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to make sense to me

@yoba-odoo yoba-odoo marked this pull request as ready for review July 19, 2024 09:48
@C3POdoo C3POdoo requested a review from a team July 19, 2024 09:50
Copy link
Contributor

@Demesmaeker Demesmaeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @yoba-odoo

Thanks for your fix, here is an improvement that could be made =]

Have a nice day!

addons/sale_loyalty/models/sale_order.py Outdated Show resolved Hide resolved
@yoba-odoo yoba-odoo force-pushed the 16.0-opw-4018909-discount_codes_shown-yoba branch 2 times, most recently from cee21df to 831926d Compare July 23, 2024 14:41
@yoba-odoo yoba-odoo force-pushed the 16.0-opw-4018909-discount_codes_shown-yoba branch from 831926d to 61b1edb Compare July 24, 2024 17:06
@Demesmaeker Demesmaeker changed the title [FIX] sale_loyalty : Don't show discounts that are already got claimed [FIX] sale_loyalty : Don't show discounts that are already claimed Jul 25, 2024
Copy link
Contributor

@Demesmaeker Demesmaeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @yoba-odoo
Thanks for your changes, could you also change the title of your commit message?
The comments left are only nitpicking comments, after that, this will be ready to merge ^^
Have a nice day,

addons/sale_loyalty/tests/test_loyalty.py Outdated Show resolved Hide resolved
addons/sale_loyalty/tests/test_loyalty.py Outdated Show resolved Hide resolved
addons/sale_loyalty/tests/test_loyalty.py Outdated Show resolved Hide resolved
addons/sale_loyalty/tests/test_loyalty.py Outdated Show resolved Hide resolved
addons/sale_loyalty/tests/test_loyalty.py Outdated Show resolved Hide resolved
Steps to reproduce:
	- Install eCommerce and Loyalty module
	- Create a Discount that is applied using code
	- Generate coupon codes
	- Modify the balance of the codes to be more than 1
	- Go to website and create an order
	- Proceed to checkout and apply one of the codes

Current behavior before PR:
The reward will be shown as claimable even after we already applied
its code. This will lead that the user can be able to claim it more
than once in the same order. This is happening becuase when getting
the claimable rewards we are fetching the rewards that already got applied.
https://github.com/odoo/odoo/blob/16.0/addons/sale_loyalty/models/sale_order.py#L655

Desired behavior after PR is merged:
We are excluding the already-applied discounts on the order to avoid
using them more than once in the same order.

opw-4018909
@yoba-odoo yoba-odoo force-pushed the 16.0-opw-4018909-discount_codes_shown-yoba branch from 61b1edb to 8046f9c Compare July 25, 2024 08:30
Copy link
Contributor

@Demesmaeker Demesmaeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your changes!

@robodoo r+

🥳

robodoo pushed a commit that referenced this pull request Jul 25, 2024
Steps to reproduce:
	- Install eCommerce and Loyalty module
	- Create a Discount that is applied using code
	- Generate coupon codes
	- Modify the balance of the codes to be more than 1
	- Go to website and create an order
	- Proceed to checkout and apply one of the codes

Current behavior before PR:
The reward will be shown as claimable even after we already applied
its code. This will lead that the user can be able to claim it more
than once in the same order. This is happening becuase when getting
the claimable rewards we are fetching the rewards that already got applied.
https://github.com/odoo/odoo/blob/16.0/addons/sale_loyalty/models/sale_order.py#L655

Desired behavior after PR is merged:
We are excluding the already-applied discounts on the order to avoid
using them more than once in the same order.

opw-4018909

closes #173555

Signed-off-by: Morgane Demesmaeker <edm@odoo.com>
@robodoo robodoo closed this Jul 25, 2024
@azl-odoo
Copy link
Contributor

azl-odoo commented Aug 8, 2024

Hi @yoba-odoo ! This change you made causes all rewards of type "discount" to disappear when any other reward is applied on the SO, even if they haven't actually been applied yet.
For exemple, we have a program with 2 reward: a free shipping reward and a discount reward, both costing a single discount point. When you trigger a rule granting 2 discount points you should be able to claim both rewards.
If you claim the discount reward first then it works fine and you can also claim the free shipping reward after.
However if you claim the free shipping reward first, then the condition you added is triggered (reward.reward_type == 'discount' and coupon in self.order_line.coupon_id) and the discount is removed from the claimable rewards.

I will let you know when the Odoo ticket is created, but I wanted to ping you so that we can hopefully get a fix as soon as possible. Don't hesitate to contact me if you want some help.
Thank you!

@fw-bot fw-bot deleted the 16.0-opw-4018909-discount_codes_shown-yoba branch August 8, 2024 12:46
@yoba-odoo
Copy link
Contributor Author

Hello @azl-odoo
Sorry for that 😅 I will try to look into it next week and ping me if any ticket got created just in case I forgot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants