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

[16.0][FIX] sale_order_product_recommendation: recommendations on sales with section or notes #3660

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

Tisho99
Copy link

@Tisho99 Tisho99 commented Apr 2, 2025

If you try to use the recommendation wizard in a sales order with section or notes, an error will be displayed when trying to get the recommendations.

The reason is because it tries to read the section's product, and it does not exist.

This PR fixes it

I-7204

@OCA-git-bot
Copy link
Contributor

Hi @yajo, @rafaelbn, @sergio-teruel,
some modules you are maintaining are being modified, check this out!

@Tisho99 Tisho99 force-pushed the 16.0-fix-sale_order_product_recommendation branch from 6ac417c to 3fe70c0 Compare April 2, 2025 07:56
@Tisho99
Copy link
Author

Tisho99 commented Apr 2, 2025

@@ -160,7 +160,9 @@ def generate_recommendations(self):
existing_product_ids = set()
# Always recommend all products already present in the linked SO except delivery
# carrier products
for line in self.order_id.order_line.filtered(lambda ln: not ln._is_delivery()):
for line in self.order_id.order_line.filtered(
lambda ln: not (ln._is_delivery() or ln.display_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test with a note or section ?

Copy link
Contributor

@Jaimermaccione Jaimermaccione left a comment

Choose a reason for hiding this comment

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

@Tisho99 LGTM Reviewed on local enviroment.

@Tisho99 Tisho99 force-pushed the 16.0-fix-sale_order_product_recommendation branch from 3fe70c0 to 63880d5 Compare April 7, 2025 15:51
@@ -127,6 +127,21 @@ def test_recommendations_ordered_by_code(self):
],
)

def test_recommendations_with_note(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you do in this test?

Copy link
Author

Choose a reason for hiding this comment

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

Generate the recomendations with the wizard in a sale order with notes. It is what gives an error without the fix

@Tisho99 Tisho99 force-pushed the 16.0-fix-sale_order_product_recommendation branch from 63880d5 to 7a0baff Compare April 8, 2025 08:00
Copy link
Contributor

@manuelregidor manuelregidor left a comment

Choose a reason for hiding this comment

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

Technical reviw. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants