-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shopfloor: add checkout option ask leaf location dest
Following this change on the checkout scenario #618 A check has been added to force the user to scan a child location if the destination location is not a leaf in the locations tree. To allow for flexibility this change adds the options to disable this feature.
- Loading branch information
Showing
7 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# 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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters