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][IMP] shopfloor_reception improve confirmation #717

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions shopfloor_reception/services/reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def _before_state__set_quantity(self, picking, line, message=None):
return self._response_for_set_quantity(picking, line, message=message)

def _response_for_set_quantity(
self, picking, line, message=None, asking_confirmation=False
self, picking, line, message=None, asking_confirmation=None
):
self._align_product_uom_qties(line.move_id)
return self._response(
Expand Down Expand Up @@ -1068,7 +1068,7 @@ def _set_quantity__get_handlers_by_type(self):
}

def _set_quantity__by_barcode(
self, picking, selected_line, barcode, confirmation=False
self, picking, selected_line, barcode, confirmation=None
):
handlers_by_type = self._set_quantity__get_handlers_by_type()
search = self._actions_for("search")
Expand All @@ -1078,12 +1078,12 @@ def _set_quantity__by_barcode(
return handler(picking, selected_line, search_result.record)
# Nothing found, ask user if we should create a new pack for the scanned
# barcode
if not confirmation:
if confirmation != barcode:
return self._response_for_set_quantity(
picking,
selected_line,
message=self.msg_store.create_new_pack_ask_confirmation(barcode),
asking_confirmation=True,
asking_confirmation=barcode,
)
package = self.env["stock.quant.package"].create({"name": barcode})
selected_line.result_package_id = package
Expand All @@ -1108,7 +1108,7 @@ def set_quantity(
selected_line_id,
quantity=None,
barcode=None,
confirmation=False,
confirmation=None,
):
"""Set the quantity done

Expand Down Expand Up @@ -1414,7 +1414,7 @@ def set_quantity(self):
},
"quantity": {"type": "float"},
"barcode": {"type": "string"},
"confirmation": {"type": "boolean"},
"confirmation": {"type": "string", "nullable": True},
}

def process_with_existing_pack(self):
Expand Down Expand Up @@ -1622,7 +1622,7 @@ def _schema_set_quantity(self):
},
"picking": {"type": "dict", "schema": self.schemas.picking()},
"confirmation_required": {
"type": "boolean",
"type": "string",
"nullable": True,
"required": False,
},
Expand Down
4 changes: 2 additions & 2 deletions shopfloor_reception/tests/test_return_scan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_scan_product_in_delivery(self):
response,
next_state="set_quantity",
data={
"confirmation_required": False,
"confirmation_required": None,
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
},
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_scan_packaging_in_delivery(self):
response,
next_state="set_quantity",
data={
"confirmation_required": False,
"confirmation_required": None,
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
},
Expand Down
2 changes: 1 addition & 1 deletion shopfloor_reception/tests/test_return_set_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _dispatch(self, quantity=None, barcode=None):

def _get_data(self):
return {
"confirmation_required": False,
"confirmation_required": None,
"picking": self.data.picking(self.return_picking),
"selected_move_line": self.data.move_lines(self.selected_move_line),
}
Expand Down
6 changes: 3 additions & 3 deletions shopfloor_reception/tests/test_select_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_scan_lot(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)

Expand All @@ -112,7 +112,7 @@ def test_scan_not_tracked_product(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)

Expand All @@ -137,7 +137,7 @@ def test_scan_not_tracked_packaging(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)

Expand Down
2 changes: 1 addition & 1 deletion shopfloor_reception/tests/test_set_lot_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ def test_ensure_expiry_date(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)
66 changes: 56 additions & 10 deletions shopfloor_reception/tests/test_set_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_set_quantity_scan_product(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)

Expand All @@ -89,7 +89,7 @@ def test_set_quantity_scan_packaging(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)

Expand All @@ -115,7 +115,7 @@ def test_scan_product(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)
# Scan again, and ensure qty increments
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_scan_packaging(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
)
# Scan again, and ensure qty increments
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_scan_package_with_destination_not_child_of_dest_location(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
message={"message_type": "error", "body": "You cannot place it here"},
)
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_scan_location_not_child_of_dest_location(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
message={"message_type": "error", "body": "You cannot place it here"},
)
Expand Down Expand Up @@ -328,7 +328,7 @@ def test_scan_location_view_usage(self):
data={
"picking": data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": False,
"confirmation_required": None,
},
message={"message_type": "error", "body": "You cannot place it here"},
)
Expand All @@ -355,7 +355,7 @@ def test_scan_new_package(self):
data={
"picking": picking_data,
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": True,
"confirmation_required": "FooBar",
},
message={
"message_type": "warning",
Expand All @@ -368,7 +368,7 @@ def test_scan_new_package(self):
"picking_id": picking.id,
"selected_line_id": selected_move_line.id,
"barcode": "FooBar",
"confirmation": True,
"confirmation": "FooBar",
},
)
self.assertEqual(selected_move_line.result_package_id.name, "FooBar")
Expand All @@ -382,6 +382,52 @@ def test_scan_new_package(self):
},
)

def test_reception_set_quantity_confirm_new_package_with_other_new_pack(self):
picking = self._create_picking()
selected_move_line = picking.move_line_ids.filtered(
lambda l: l.product_id == self.product_a
)
selected_move_line.shopfloor_user_id = self.env.uid
# Scan new pack 1
response = self.service.dispatch(
"set_quantity",
params={
"picking_id": picking.id,
"selected_line_id": selected_move_line.id,
"barcode": "Pack1",
},
)
data = {
"picking": self.data.picking(picking),
"selected_move_line": self.data.move_lines(selected_move_line),
"confirmation_required": "Pack1",
}
# System ask for confimation for Pack 1
self.assert_response(
response,
next_state="set_quantity",
data=data,
message=self.msg_store.create_new_pack_ask_confirmation("Pack1"),
)
# Scan new pack 2
response = self.service.dispatch(
"set_quantity",
params={
"picking_id": picking.id,
"selected_line_id": selected_move_line.id,
"barcode": "Pack2",
"confirmation": "Pack1",
},
)
# System ask for confimation for Pack 2
data["confirmation_required"] = "Pack2"
self.assert_response(
response,
next_state="set_quantity",
data=data,
message=self.msg_store.create_new_pack_ask_confirmation("Pack2"),
)

@classmethod
def _shopfloor_manager_values(cls):
vals = super()._shopfloor_manager_values()
Expand Down Expand Up @@ -516,7 +562,7 @@ def test_concurrent_update(self):
data={
"picking": picking_data,
"selected_move_line": self.data.move_lines(line),
"confirmation_required": False,
"confirmation_required": None,
},
message=error_msg,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const reception_states = function () {
selected_line_id: this.line_being_handled.id,
quantity: this.scan_destination_qty,
barcode: barcode.text,
confirmation: this.state.data.confirmation_required,
confirmation: this.state.data.confirmation_required || "",
})
);
},
Expand Down Expand Up @@ -240,6 +240,7 @@ export const reception_states = function () {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
location_name: location.text,
// FIXME if it is always set to true, it is not really used ?
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we fix it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually not. This is not the same endpoint that is called. So this one has not been changed.
Because the frontend always return true, I did not see the point of updating it, maybe the question is should it be removed ?

confirmation: true,
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_set_multiple_packaging_dimension(self):
data={
"picking": self.data.picking(self.picking),
"selected_move_line": self.data.move_lines(line),
"confirmation_required": False,
"confirmation_required": None,
},
message=self.msg_store.packaging_dimension_updated(
self.product_c_packaging_2
Expand Down
Loading