-
-
Notifications
You must be signed in to change notification settings - Fork 196
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][IMP] shopfloor: add decorator to gracefully handle exceptions on response #768
Open
TDu
wants to merge
5
commits into
OCA:14.0
Choose a base branch
from
camptocamp:14-sf-catch-exceptions
base: 14.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e3c0779
sf_base: add decorator to gracefully handle exceptions
TDu 6ac2d67
shpfloor: use catch_error decorator in zp, spt
TDu c0b26dc
Add shopfloor_location_package_restriction
TDu 96812b3
fixup! sf_base: add decorator to gracefully handle exceptions
TDu 041e7e5
fixup! fixup! sf_base: add decorator to gracefully handle exceptions
TDu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...shopfloor_location_package_restriction/odoo/addons/shopfloor_location_package_restriction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../shopfloor_location_package_restriction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
{ | ||
"name": "Shopfloor Location Package Restriction", | ||
"summary": "Glue module between shopfloor and location package restriction", | ||
"version": "14.0.1.0.0", | ||
"category": "Inventory", | ||
"website": "https://github.com/OCA/wms", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"shopfloor", | ||
# OCA/stock-logistics-warehouse | ||
"stock_location_package_restriction", | ||
], | ||
"auto_install": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Thierry Ducrest <thierry.ducrest@camptocamp.com> |
7 changes: 7 additions & 0 deletions
7
shopfloor_location_package_restriction/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Glue module between `shopfloor` and `stock_location_package_restriction`. | ||
It allows to send proper error message to the frontend instead of a stack | ||
trace error being displayed. | ||
|
||
Finally his only use is to test. | ||
|
||
Should be removed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import test_single_pack_transfer_force_package | ||
from . import test_zone_picking_force_package |
69 changes: 69 additions & 0 deletions
69
shopfloor_location_package_restriction/tests/test_single_pack_transfer_force_package.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo.addons.shopfloor.tests.test_single_pack_transfer_base import ( | ||
SinglePackTransferCommonBase, | ||
) | ||
|
||
|
||
class TestSinglePackTransferForcePackage(SinglePackTransferCommonBase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
# Prepare the pack and related picking has started | ||
cls.pack_a = cls.env["stock.quant.package"].create( | ||
{"location_id": cls.stock_location.id} | ||
) | ||
cls.quant_a = ( | ||
cls.env["stock.quant"] | ||
.sudo() | ||
.create( | ||
{ | ||
"product_id": cls.product_a.id, | ||
"location_id": cls.shelf1.id, | ||
"quantity": 1, | ||
"package_id": cls.pack_a.id, | ||
} | ||
) | ||
) | ||
cls.picking = cls._create_initial_move(lines=[(cls.product_a, 1)]) | ||
cls.move_line = cls.picking.move_line_ids | ||
cls.package_level = cls.move_line.package_level_id | ||
cls.package_level.is_done = True | ||
cls.picking.move_line_ids.qty_done = 1 | ||
# Add restriction on destination location | ||
cls.shelf2.sudo().package_restriction = "singlepackage" | ||
# Add a package on the destination location | ||
cls.pack_1 = cls.env["stock.quant.package"].create( | ||
{"location_id": cls.shelf2.id} | ||
) | ||
cls._update_qty_in_location( | ||
cls.shelf2, | ||
cls.product_a, | ||
1, | ||
package=cls.pack_1, | ||
) | ||
|
||
def test_scan_location_has_restrictions(self): | ||
""" """ | ||
response = self.service.dispatch( | ||
"validate", | ||
params={ | ||
"package_level_id": self.package_level.id, | ||
"location_barcode": self.shelf2.barcode, | ||
}, | ||
) | ||
message = { | ||
"message_type": "error", | ||
"body": ( | ||
f"Only one package is allowed on the location " | ||
f"{self.shelf2.display_name}.You cannot add " | ||
f"the {self.move_line.package_id.name}, there is already {self.pack_1.name}." | ||
), | ||
} | ||
self.assert_response( | ||
response, | ||
next_state="scan_location", | ||
data=self.ANY, | ||
message=message, | ||
) |
50 changes: 50 additions & 0 deletions
50
shopfloor_location_package_restriction/tests/test_zone_picking_force_package.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2023 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo.addons.shopfloor.tests.test_zone_picking_base import ZonePickingCommonCase | ||
|
||
|
||
class TestZonePickingForcePackage(ZonePickingCommonCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.service.work.current_picking_type = self.picking1.picking_type_id | ||
|
||
def test_set_destination_location_package_restriction(self): | ||
"""Check error restriction on location is properly forwarded to frontend.""" | ||
# Add a restriction on the location | ||
self.packing_location.sudo().package_restriction = "singlepackage" | ||
# Add a first package on the location | ||
self.pack_1 = self.env["stock.quant.package"].create( | ||
{"location_id": self.packing_location.id} | ||
) | ||
self._update_qty_in_location( | ||
self.packing_location, self.product_a, 1, package=self.pack_1 | ||
) | ||
picking_type = self.picking1.picking_type_id | ||
move_line = self.picking1.move_lines.move_line_ids | ||
move_line.qty_done = move_line.product_uom_qty | ||
response = self.service.dispatch( | ||
"set_destination", | ||
params={ | ||
"move_line_id": move_line.id, | ||
"barcode": self.packing_location.barcode, | ||
"quantity": move_line.product_uom_qty, | ||
"confirmation": False, | ||
}, | ||
) | ||
message = { | ||
"message_type": "error", | ||
"body": ( | ||
f"Only one package is allowed on the location " | ||
f"{self.packing_location.display_name}.You cannot add " | ||
f"the {move_line.package_id.name}, there is already {self.pack_1.name}." | ||
), | ||
} | ||
self.assert_response_set_line_destination( | ||
response, | ||
self.zone_location, | ||
picking_type, | ||
move_line, | ||
message=message, | ||
qty_done=10.0, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would prefer this name, not blocking