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

[14.0][ADD] shopfloor_location_package_restriction #732

Closed
wants to merge 5 commits into from

Conversation

TDu
Copy link
Member

@TDu TDu commented Aug 25, 2023

Needs : OCA/stock-logistics-warehouse#1797

This 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

@OCA-git-bot
Copy link
Contributor

Hi @simahawk, @sebalix, @guewen,
some modules you are maintaining are being modified, check this out!

@TDu TDu changed the title [14.0] [14.0][ADD] shopfloor_location_package_restriction Aug 25, 2023
Comment on lines 872 to 903
message = self._validate_destination(location, move_line.move_id)
if message:
Copy link
Member

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 😉

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

aha

@TDu TDu force-pushed the 14-sf-stock-location-pack-glue branch from c413c86 to 68614aa Compare August 29, 2023 06:54
Copy link
Contributor

@jbaudoux jbaudoux left a 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:
Copy link
Contributor

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

Copy link
Member Author

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 ?

shopfloor/actions/message.py Outdated Show resolved Hide resolved
Comment on lines 208 to 218
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
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did.

shopfloor/services/zone_picking.py Outdated Show resolved Hide resolved
@mmequignon
Copy link
Member

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

This is basically what I did here (except that I'm not looking for exceptions).
https://github.com/OCA/wms/blob/14.0/shopfloor_single_product_transfer/services/single_product_transfer.py#L18
Then you decorate your methods with this and you're good.
Not very flexible atm, but it can be improved for more generic needs.
For instance, we could pass a list of blocking message types and a list exceptions, which would trigger a rollback

@with_savepoint(blocking_types=["error"], blocking_exceptions=[UserError, ValidationError])
def my_endpoints(...)

@jbaudoux
Copy link
Contributor

jbaudoux commented Sep 6, 2023

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

This is basically what I did here (except that I'm not looking for exceptions). https://github.com/OCA/wms/blob/14.0/shopfloor_single_product_transfer/services/single_product_transfer.py#L18 Then you decorate your methods with this and you're good. Not very flexible atm, but it can be improved for more generic needs. For instance, we could pass a list of blocking message types and a list exceptions, which would trigger a rollback

@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 ?

@mmequignon
Copy link
Member

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

This is basically what I did here (except that I'm not looking for exceptions). https://github.com/OCA/wms/blob/14.0/shopfloor_single_product_transfer/services/single_product_transfer.py#L18 Then you decorate your methods with this and you're good. Not very flexible atm, but it can be improved for more generic needs. For instance, we could pass a list of blocking message types and a list exceptions, which would trigger a rollback

@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.
Let's have a call about that.

@TDu TDu force-pushed the 14-sf-stock-location-pack-glue branch from 7453be2 to 282efe9 Compare September 8, 2023 07:22
@TDu TDu force-pushed the 14-sf-stock-location-pack-glue branch from 282efe9 to d9a3123 Compare October 13, 2023 09:56
@TDu TDu force-pushed the 14-sf-stock-location-pack-glue branch from d9a3123 to 65d4134 Compare October 13, 2023 12:51
@TDu
Copy link
Member Author

TDu commented Oct 17, 2023

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

I have opened this PR #768 that implements a way to handle any ValidationError when handling a response.

It could replace this one

@mmequignon
Copy link
Member

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

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:
Such as, rollback in case of error, or error management.

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

Successfully merging this pull request may close these issues.

4 participants