-
-
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: package checkout buttons #665
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,8 @@ | |
{ | ||
"no_prefill_qty": true, | ||
"show_oneline_package_content": true, | ||
"auto_post_line": true | ||
"auto_post_line": true, | ||
"package_process_type": true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to add a migration for this change as well. def post_init_hook(cr, registry): |
||
} | ||
</field> | ||
</record> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,17 @@ class ShopfloorMenu(models.Model): | |
compute="_compute_auto_post_line_is_possible" | ||
) | ||
|
||
package_process_type_is_possible = fields.Boolean( | ||
compute="_compute_package_process_type_is_possible" | ||
) | ||
package_process_type = fields.Selection( | ||
[ | ||
("without_package", "Without Package"), | ||
("with_package", "With Package"), | ||
], | ||
"Package Proccess Type", | ||
) | ||
Comment on lines
+199
to
+208
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to move the configuration to the picking type in a separate module e.g. |
||
|
||
@api.onchange("unload_package_at_destination") | ||
def _onchange_unload_package_at_destination(self): | ||
# Uncheck pick_pack_same_time when unload_package_at_destination is set to True | ||
|
@@ -411,3 +422,10 @@ def _compute_allow_alternative_destination_is_possible(self): | |
menu.allow_alternative_destination_is_possible = ( | ||
menu.scenario_id.has_option("allow_alternative_destination") | ||
) | ||
|
||
@api.depends("scenario_id") | ||
def _compute_package_process_type_is_possible(self): | ||
for menu in self: | ||
menu.package_process_type_is_possible = menu.scenario_id.has_option( | ||
"package_process_type" | ||
) |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -83,19 +83,28 @@ def _response_for_manual_selection(self, message=None): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
return self._response(next_state="manual_selection", data=data, message=message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def _response_for_select_package(self, picking, lines, message=None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
with_pack, wo_pack = self._get_allow_package_options() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return self._response( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
next_state="select_package", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"selected_move_lines": self._data_for_move_lines(lines.sorted()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"picking": self.data.picking(picking), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"packing_info": self._data_for_packing_info(picking), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"no_package_enabled": not self.options.get( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"checkout__disable_no_package" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"allow_with_package": with_pack, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"allow_without_package": wo_pack, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+93
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second one should be |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
message=message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def _get_allow_package_options(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if not self.work.menu.package_process_type: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return True, True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.work.menu.package_process_type == "with_package": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return True, False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return False, True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+99
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should split this into two separate methods. This would simplify the code later.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def _data_for_packing_info(self, picking): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"""Return the packing information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -913,11 +922,37 @@ def scan_package_action(self, picking_id, selected_line_ids, barcode): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_lines = self.env["stock.move.line"].browse(selected_line_ids).exists() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
search_result = self._scan_package_find(picking, barcode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
message = self._check_scan_package_find_result(search_result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return self._response_for_select_package( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
picking, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_lines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
message=message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
result_handler = getattr( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
self, "_scan_package_action_from_" + search_result.type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return result_handler(picking, selected_lines, search_result.record) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def _check_scan_package_find_result(self, search_result): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ppt = self.work.menu.package_process_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Currently there is no known way to finish the checkout with a scan. To | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# process without any package is only possible with a button. In its def | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# a BadRequest is raised in case no package is not allowed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if not ppt or ppt == "with_package": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stype = search_result.type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if ppt == "without_package" and stype in [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"package", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"packaging", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
packaging is a product packaging. This must be allowed |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"delivery_packaging", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return self.msg_store.invalid_scanned_checkout_object_wo_package(stype, ppt) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+939
to
+955
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add a docstring and rename this method.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def _scan_package_find(self, picking, barcode, search_types=None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
search = self._actions_for("search") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
search_types = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -1087,7 +1122,7 @@ def no_package(self, picking_id, selected_line_ids): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Transitions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* select_line: goes back to selection of lines to work on next lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.options.get("checkout__disable_no_package"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.work.menu.package_process_type == "with_package": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
raise BadRequest("`checkout.no_package` endpoint is not enabled") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
picking = self.env["stock.picking"].browse(picking_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
message = self._check_picking_status(picking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -1562,7 +1597,12 @@ def _states(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
"select_package": dict( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
self._schema_selected_lines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
packing_info={"type": "string", "nullable": True}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
no_package_enabled={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
allow_with_package={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"type": "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"nullable": True, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"required": False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
allow_without_package={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"type": "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"nullable": True, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"required": False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Could you rename this to checkout_package_scan_is_not_allowed