-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
[14.0][ADD] shopfloor_location_package_restriction #732
Conversation
shopfloor/services/zone_picking.py
Outdated
message = self._validate_destination(location, move_line.move_id) | ||
if message: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a handler to me 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks like a nail when you have a hammer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha
c413c86
to
68614aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing many glue modules for catching validation errors can't we catch any validation error, rollback the transaction and return the error ?
Here you solved the ValidationError from location_package_restriction, but there will be the same issue with location_product_restriction
cc @simahawk @lmignon
error = self.msg_store.location_not_allowed() | ||
if error: | ||
return self._set_destination_all_response(buffer_lines, message=error) | ||
if not message: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else:
would be easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the next if
clause ? But no because the first if
could return a message ?
def _validate_destination_location(self, package_level, location): | ||
moves = package_level.move_line_ids.move_id | ||
if not location: | ||
return self._response_for_scan_location( | ||
package_level, message=self.msg_store.no_location_found() | ||
) | ||
if not self.is_dest_location_valid(moves, location): | ||
return self._response_for_scan_location( | ||
package_level, message=self.msg_store.dest_location_not_allowed() | ||
) | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we move this to service level instead of repeating it in each service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did.
This is basically what I did here (except that I'm not looking for exceptions). @with_savepoint(blocking_types=["error"], blocking_exceptions=[UserError, ValidationError])
def my_endpoints(...) |
How do you build properly the response to pass all the right arguments ? |
I'm not sure to understand your question. |
7453be2
to
282efe9
Compare
282efe9
to
d9a3123
Compare
d9a3123
to
65d4134
Compare
I have opened this PR #768 that implements a way to handle any ValidationError when handling a response. It could replace this one |
We're still missing what was the requirement in this case: |
Needs : OCA/stock-logistics-warehouse#1797This is not a good solution of the problem, needing 1 shopfloor module to nicely handle the errors/exception of another module.
A generic solution for this problem can be seen in #768
ref.: rau-200