Skip to content

Commit

Permalink
Merge PR #783 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Dec 8, 2023
2 parents 67cdc0b + 4ec61c5 commit d29c2af
Show file tree
Hide file tree
Showing 20 changed files with 728 additions and 10 deletions.
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"),
# 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 <thierry.ducrest@camptocamp.com>
* Joshua Lauer <joshua.lauer@raumschmiede.de>

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 <thierry.ducrest@camptocamp.com>
* Joshua Lauer <joshua.lauer@raumschmiede.de>
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
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)
Loading

0 comments on commit d29c2af

Please sign in to comment.