Skip to content

Conversation

@ced-adhoc
Copy link
Contributor

@ced-adhoc ced-adhoc commented Dec 19, 2024

This fix replaces the UserError in _onchange_quantity with a warning message. Now, users receive a non-blocking notification when attempting to return more products that delivered, but allows them to modify the quantity before proceeding.

The restriction logic remains unchanged for _create_returns, ensuring hard enforcement at the validation stage.

  • Improves UX by preventing unnecessary hard errors on simple mistakes.
  • Maintains the business rule enforcement while allowing users to correct their input easily.

Copy link

@luc-adhoc luc-adhoc left a comment

Choose a reason for hiding this comment

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

functional review

qty = self.get_returned_restricted_quantity(self.move_id)

if restrict_return_qty and self.quantity > qty:
raise UserError(_("Return more quantities than delivered is not allowed."))
Copy link
Contributor

Choose a reason for hiding this comment

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

@ced-adhoc You remove here a fucntionality. Maybe in order to get user warned before validating the return should be to add an alert on the wizard form (if it is possible) or by other mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rousseldenis Hi! I'm taking up this task based on you suggestion. I replaced the UserError with a warning in the onchange quantity method, and it seems to work as expected. Could you please review it again and let me know your thoughts? Thanks!

@rousseldenis rousseldenis added this to the 16.0 milestone Dec 20, 2024
@mav-adhoc
Copy link
Contributor

@rousseldenis What's the point to put the UserError on an onchange_quantity method if either way the quantity restriction will be validated when clicking on the return button? It looks redundant. It makes any difference? Sorry to ask! I was just wondering because it doesn't make too much sense to me.

@ced-adhoc ced-adhoc requested a review from rousseldenis January 6, 2025 15:39
@ced-adhoc
Copy link
Contributor Author

@rousseldenis Hi! I'm taking up this task based on you suggestion. I replaced the UserError with a warning in the onchange quantity method, and it seems to work as expected. Could you please review it again and let me know your thoughts? Thanks!

Copy link

@florenciafrigieri2 florenciafrigieri2 left a comment

Choose a reason for hiding this comment

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

Test working ok.
When the restriction is set in the operation type, Odoo is not allowing to return bigger quantities. If you have a mistake, it is possible to correct it.

@ced-adhoc
Copy link
Contributor Author

Hi @rousseldenis could you please check this fix? Thanks in advance!

@ced-adhoc
Copy link
Contributor Author

Hi @rousseldenis could you please check this? thanks!

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 13, 2025
@pedrobaeza
Copy link
Member

The idea to raise a UserError is to rollback the quantity to the previous one. With this change, it won't be rollbacked, and then, it's possible to validate a picking returning more quantity, which is not correct.

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 20, 2025
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.

7 participants