Skip to content

Commit

Permalink
fixup! Add shopfloor_location_package_restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Oct 13, 2023
1 parent b10bbf6 commit 18f62fd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 42 deletions.
3 changes: 1 addition & 2 deletions shopfloor_location_package_restriction/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import single_pack_transfer
from . import zone_picking
from . import service
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


from odoo.exceptions import ValidationError

from odoo.addons.component.core import Component
from odoo.addons.component.core import AbstractComponent


class BaseShopfloorProcess(AbstractComponent):

class ShopfloorZonePicking(Component):
_inherit = "shopfloor.zone.picking"
_inherit = "base.shopfloor.process"

def _validate_destination(self, location, moves):
message = super()._validate_destination(location, moves)
def validate_dest_location(self, moves, location):
message = super().validate_dest_location(moves, location)
if message:
return message
if location.package_restriction != "norestriction":
if location.package_restriction:
try:
moves._check_location_package_restriction(only_qty_done=False)
except ValidationError as ex:
# __import__("pdb").set_trace()
return {
"message_type": "error",
"body": ex.name,
}
# return self.msg_store.location_has_restrictions()

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ def setUpClass(cls):
)
)
cls.picking = cls._create_initial_move(lines=[(cls.product_a, 1)])
cls.package_level = cls.picking.move_line_ids.package_level_id
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.env["stock.quant.package"].create(
{"location_id": cls.shelf2.id}
),
package=cls.pack_1,
)

def test_scan_location_has_restrictions(self):
Expand All @@ -51,9 +53,17 @@ def test_scan_location_has_restrictions(self):
"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=self.service.msg_store.location_has_restrictions(),
message=message,
)

0 comments on commit 18f62fd

Please sign in to comment.