From 4dfc22f11b9b67c06b886db33defde76a4dd5f7f Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 26 Jun 2020 09:49:16 +0200 Subject: [PATCH] Fix issues in Pick mode * The change of destination location was not updated on the screen when the barcode was scanned (it was when the "manual barcode wizard" is used though) * We should be able to pick partially available move lines * prevent to scan a location when no move line is selected or the move line has already been set to done --- .../models/vertical_lift_operation_pick.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/stock_vertical_lift/models/vertical_lift_operation_pick.py b/stock_vertical_lift/models/vertical_lift_operation_pick.py index d793ab785..04d5d795d 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_pick.py +++ b/stock_vertical_lift/models/vertical_lift_operation_pick.py @@ -11,9 +11,16 @@ class VerticalLiftOperationPick(models.Model): def on_barcode_scanned(self, barcode): self.ensure_one() + if not self.current_move_line_id or self.current_move_line_id == "done": + return location = self.env["stock.location"].search([("barcode", "=", barcode)]) if location: self.current_move_line_id.location_dest_id = location + # even if location_dest_id is a related, we need to set it, otherwise + # it's not refreshed on the view. We need both updates otherwise the + # line is not updated, probably because on_barcode_scanner is called + # in an onchange. (Even if the related is not readonly, tested.) + self.location_dest_id = location self.operation_descr = _("Save") else: self.env.user.notify_warning( @@ -21,9 +28,8 @@ class VerticalLiftOperationPick(models.Model): ) def _domain_move_lines_to_do(self): - # TODO check domain domain = [ - ("state", "=", "assigned"), + ("state", "in", ("assigned", "partially_available")), ("location_id", "child_of", self.location_id.id), ] return domain @@ -32,9 +38,8 @@ class VerticalLiftOperationPick(models.Model): shuttle_locations = self.env["stock.location"].search( [("vertical_lift_kind", "=", "view")] ) - # TODO check domain domain = [ - ("state", "=", "assigned"), + ("state", "in", ("assigned", "partially_available")), ("location_id", "child_of", shuttle_locations.ids), ] return domain @@ -43,10 +48,8 @@ class VerticalLiftOperationPick(models.Model): self.current_move_line_id.fetch_vertical_lift_tray_source() def process_current(self): - # test code, TODO the smart one - # (scan of barcode increments qty, save calls action_done?) line = self.current_move_line_id - if line.state != "done": + if line.state in ("assigned", "partially_available"): line.qty_done = line.product_qty line.move_id._action_done()