-
-
Notifications
You must be signed in to change notification settings - Fork 195
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] shopfloor: add checkout option ask leaf location dest #775
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2023 Camptocamp SA (http://www.camptocamp.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import json | ||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
checkout_scenario = env["shopfloor.scenario"].search([("key", "=", "checkout")]) | ||
_update_scenario_options(checkout_scenario) | ||
checkout_menus = env["shopfloor.menu"].search( | ||
[("scenario_id", "=", checkout_scenario.id)] | ||
) | ||
_enable_option_in_menus(checkout_menus) | ||
|
||
|
||
def _update_scenario_options(scenario): | ||
options = scenario.options | ||
options["ask_for_leaf_destination_location"] = True | ||
options_edit = json.dumps(options or {}, indent=4, sort_keys=True) | ||
scenario.write({"options_edit": options_edit}) | ||
_logger.info( | ||
"Option ask_for_leaf_destination_location added to the Checkout scenario" | ||
) | ||
|
||
|
||
def _enable_option_in_menus(menus): | ||
for menu in menus: | ||
menu.ask_for_leaf_destination_location = True | ||
_logger.info( | ||
"Option ask_for_leaf_destination_location enabled for menu {}".format( | ||
menu.name | ||
) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1405,13 +1405,14 @@ def done(self, picking_id, confirmation=False): | |
) | ||
lines_done = self._lines_checkout_done(picking) | ||
dest_location = picking.location_dest_id | ||
child_locations = self.env["stock.location"].search( | ||
[("id", "child_of", dest_location.id), ("usage", "!=", "view")] | ||
) | ||
if len(child_locations) > 0 and child_locations != dest_location: | ||
return self._response_for_select_child_location( | ||
picking, | ||
if self.work.menu.ask_for_leaf_destination_location: | ||
child_locations = self.env["stock.location"].search( | ||
[("id", "child_of", dest_location.id), ("usage", "!=", "view")] | ||
) | ||
if len(child_locations) > 0 and child_locations != dest_location: | ||
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. Can we simply test if 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. Odoo std allows to put internal locations inside internal ones, so checking only usage == Now I'm not sure about the current implementation of this feature, see my comment above. 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. Following sebalix remark that we are processing multiple moves, use this condition: |
||
return self._response_for_select_child_location( | ||
picking, | ||
) | ||
stock = self._actions_for("stock") | ||
stock.validate_moves(lines_done.move_id) | ||
return self._response_for_select_document( | ||
|
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.
Should be the move destination location
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.
There is something fishy there:
picking
, so we could get several moves as well, each having a different destination location (e.g. a sub-location of the picking destination location thanks to a put-away)Right now this code is asking the user to scan a leaf location even if it's probably not necessary IMO 🤔
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.
We should always scan a destination if the moves target different destinations