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][ADD] shopfloor_checkout_putinpack_restriction #783

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
6 changes: 6 additions & 0 deletions setup/shopfloor_checkout_putinpack_restriction/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
35 changes: 27 additions & 8 deletions shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,20 @@ def _response_for_manual_selection(self, message=None):
data = {"pickings": self.data.pickings(pickings)}
return self._response(next_state="manual_selection", data=data, message=message)

def _data_response_for_select_package(self, picking, lines):
return {
"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"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we mark this option as deprecated (replaced by shopfloor_checkout_putinpack_restriction) and to drop in future versions?
cc @simahawk

# Used by inheriting module
"package_allowed": True,
}

def _response_for_select_package(self, picking, lines, message=None):
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"
),
},
data=self._data_response_for_select_package(picking, lines),
message=message,
)

Expand Down Expand Up @@ -960,6 +963,13 @@ 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(picking, search_result)
if message:
return self._response_for_select_package(
picking,
selected_lines,
message=message,
)
result_handler = getattr(
self, "_scan_package_action_from_" + search_result.type
)
Expand All @@ -984,6 +994,10 @@ def _scan_package_find(self, picking, barcode, search_types=None):
),
)

def _check_scan_package_find(self, picking, search_result):
# Used by inheriting modules
return False

def _find_line_to_increment(self, product_lines):
"""Find which line should have its qty incremented.

Expand Down Expand Up @@ -1679,6 +1693,11 @@ def _states(self):
"nullable": True,
"required": False,
},
package_allowed={
"type": "boolean",
"nullable": True,
"required": False,
},
),
"change_quantity": self._schema_selected_lines,
"select_dest_package": self._schema_select_package,
Expand Down
1 change: 1 addition & 0 deletions shopfloor/tests/test_checkout_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def _assert_select_package_qty_above(self, response, picking):
"picking": self._picking_summary_data(picking),
"packing_info": "",
"no_package_enabled": True,
"package_allowed": True,
},
message={
"message_type": "warning",
Expand Down
1 change: 1 addition & 0 deletions shopfloor/tests/test_checkout_list_delivery_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def test_list_delivery_packaging_not_available(self):
"no_package_enabled": not self.service.options.get(
"checkout__disable_no_package"
),
"package_allowed": True,
},
message=self.service.msg_store.no_delivery_packaging_available(),
)
1 change: 1 addition & 0 deletions shopfloor/tests/test_checkout_scan_package_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def test_scan_package_action_scan_package_keep_source_package_error(self):
"no_package_enabled": not self.service.options.get(
"checkout__disable_no_package"
),
"package_allowed": True,
},
message=self.service.msg_store.dest_package_not_valid(pack1),
)
Expand Down
2 changes: 2 additions & 0 deletions shopfloor/tests/test_checkout_select_package_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def _assert_selected_response(
message=None,
packing_info="",
no_package_enabled=True,
package_allowed=True,
):
picking = selected_lines.mapped("picking_id")
self.assert_response(
Expand All @@ -22,6 +23,7 @@ def _assert_selected_response(
"picking": self._picking_summary_data(picking),
"packing_info": packing_info,
"no_package_enabled": no_package_enabled,
"package_allowed": package_allowed,
},
message=message,
)
Expand Down
97 changes: 97 additions & 0 deletions shopfloor_checkout_putinpack_restriction/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
==========================================
Shopfloor Checkout Put In Pack Restriction
==========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c41308e3379843fe0566e62fdc74629ab919e92f8206447846a761d238cbbc5b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/14.0/shopfloor_checkout_putinpack_restriction
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-shopfloor_checkout_putinpack_restriction
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/wms&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the checkout scenario of the shopfloor module.
And depends on `stock_picking_putinpack_restriction` from
`stock-logistic-workflow`.

It restricts the display of the put in pack buttons from the
`select_package` state.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/wms/issues/new?body=module:%20shopfloor_checkout_putinpack_restriction%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp
* BCIM
* Raumschmiede

Contributors
~~~~~~~~~~~~

* Thierry Ducrest <[email protected]>
* Joshua Lauer <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-TDu| image:: https://github.com/TDu.png?size=40px
:target: https://github.com/TDu
:alt: TDu

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-TDu|

This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/14.0/shopfloor_checkout_putinpack_restriction>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions shopfloor_checkout_putinpack_restriction/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import actions
from . import services
21 changes: 21 additions & 0 deletions shopfloor_checkout_putinpack_restriction/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Shopfloor Checkout Put In Pack Restriction",
"summary": "",
"version": "14.0.1.0.0",
"development_status": "Alpha",
"category": "Inventory",
"website": "https://github.com/OCA/wms",
"author": "Camptocamp, BCIM, Raumschmiede, Odoo Community Association (OCA)",
"maintainers": ["TDu"],
"license": "AGPL-3",
"depends": [
# OCA/wms
"shopfloor",
# OCA/stock-logistics-workflow
"stock_picking_putinpack_restriction",
],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import message
15 changes: 15 additions & 0 deletions shopfloor_checkout_putinpack_restriction/actions/message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import _

from odoo.addons.component.core import Component


class MessageAction(Component):
_inherit = "shopfloor.message.action"

def package_not_allowed_for_operation(self):
return {
"message_type": "error",
"body": _("The operation does not allow the use of package"),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Thierry Ducrest <[email protected]>
TDu marked this conversation as resolved.
Show resolved Hide resolved
* Joshua Lauer <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module extends the checkout scenario of the shopfloor module.
And depends on `stock_picking_putinpack_restriction` from
`stock-logistic-workflow`.

It restricts the display of the put in pack buttons from the
`select_package` state.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import checkout
23 changes: 23 additions & 0 deletions shopfloor_checkout_putinpack_restriction/services/checkout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)


from odoo.addons.component.core import Component


class Checkout(Component):
_inherit = "shopfloor.checkout"

def _data_response_for_select_package(self, picking, lines, message=None):
res = super()._data_response_for_select_package(picking, lines)
if picking.put_in_pack_restriction == "no_package":
res["package_allowed"] = False
elif picking.put_in_pack_restriction == "with_package":
res["no_package_enabled"] = False
Comment on lines +13 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

I would make the rule clear here, without relying on the default value of shopfloor.

        if picking.put_in_pack_restriction == "no_package":
            res["package_allowed"] = False
            res["no_package_enabled"] = True
        elif picking.put_in_pack_restriction == "with_package":
            res["package_allowed"] = True
            res["no_package_enabled"] = False

And when we'll remove the no_package_enabled option we won't need to think too much.

return res

def _check_scan_package_find(self, picking, search_result):
if search_result.type in ["package", "delivery_packaging"]:
if picking.put_in_pack_restriction == "no_package":
return self.msg_store.package_not_allowed_for_operation()
return super()._check_scan_package_find(picking, search_result)

Check warning on line 23 in shopfloor_checkout_putinpack_restriction/services/checkout.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_checkout_putinpack_restriction/services/checkout.py#L23

Added line #L23 was not covered by tests
Loading
Loading