Skip to content

Commit

Permalink
[16.0][MIG] shopfloor_reception
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Nov 25, 2024
1 parent 6e912d8 commit 218e349
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 105 deletions.
1 change: 1 addition & 0 deletions setup/shopfloor_reception/odoo/addons/shopfloor_reception
6 changes: 6 additions & 0 deletions setup/shopfloor_reception/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,
)
6 changes: 3 additions & 3 deletions shopfloor/actions/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StockAction(Component):
def _create_return_move__get_max_qty(self, origin_move):
"""Returns the max returneable qty."""
# The max returnable qty is the sent qty minus the already returned qties
quantity = origin_move.reserved_qty
quantity = origin_move.product_uom_qty
for move in origin_move.move_dest_ids:
if (
move.origin_returned_move_id
Expand All @@ -28,7 +28,7 @@ def _create_return_move__get_max_qty(self, origin_move):
if move.state in ("partially_available", "assigned"):
quantity -= sum(move.move_line_ids.mapped("reserved_qty"))
elif move.state in ("done"):
quantity -= move.reserved_qty
quantity -= move.product_uom_qty
return float_round(
quantity, precision_rounding=origin_move.product_id.uom_id.rounding
)
Expand Down Expand Up @@ -92,7 +92,7 @@ def create_return_move(self, return_picking, origin_moves):
def _create_return_picking__get_vals(self, return_types, origin):
return_type = fields.first(return_types)
return {
"move_lines": [],
"move_ids": [],
"picking_type_id": return_type.id,
"state": "draft",
"origin": origin,
Expand Down
11 changes: 6 additions & 5 deletions shopfloor_reception/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Shopfloor Reception
: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_reception
:target: https://github.com/OCA/wms/tree/16.0/shopfloor_reception
: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_reception
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_reception
: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
:target: https://runboat.odoo-community.org/builds?repo=OCA/wms&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -47,7 +47,7 @@ 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_reception%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/wms/issues/new?body=module:%20shopfloor_reception%0Aversion:%2016.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.

Expand All @@ -66,6 +66,7 @@ Contributors
* Juan Miguel Sánchez Arce <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>
* Michael Tietz (MT Software) <[email protected]>
* Souheil Bejaoui <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -91,6 +92,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mmequignon| |maintainer-JuMiSanAr|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion shopfloor_reception/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Shopfloor Reception",
"summary": "Reception scenario for shopfloor",
"version": "14.0.2.10.0",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "Inventory",
"website": "https://github.com/OCA/wms",
Expand Down
1 change: 1 addition & 0 deletions shopfloor_reception/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* Juan Miguel Sánchez Arce <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>
* Michael Tietz (MT Software) <[email protected]>
* Souheil Bejaoui <[email protected]>
20 changes: 10 additions & 10 deletions shopfloor_reception/services/reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def _scan_line__by_product__return(self, picking, product):
return self._scan_line__find_or_create_line(picking, return_move)

def _scan_line__by_product(self, picking, product):
moves = picking.move_lines.filtered(lambda m: m.product_id == product)
moves = picking.move_ids.filtered(lambda m: m.product_id == product)
# Only create a return if don't already have a maching reception move
if not moves and self.work.menu.allow_return:
response = self._scan_line__by_product__return(picking, product)
Expand Down Expand Up @@ -471,7 +471,7 @@ def _scan_line__by_packaging__return(self, picking, packaging):
)

def _scan_line__by_packaging(self, picking, packaging):
move = picking.move_lines.filtered(
move = picking.move_ids.filtered(
lambda m: packaging in m.product_id.packaging_ids
)
# Only create a return if don't already have a maching reception move
Expand Down Expand Up @@ -708,7 +708,7 @@ def _data_for_stock_picking(self, picking, with_lines=False, **kw):
kw["with_progress"] = True
data = self.data.picking(picking, **kw)
if with_lines:
data.update({"moves": self._data_for_moves(picking.move_lines)})
data.update({"moves": self._data_for_moves(picking.move_ids)})
return data

def _data_for_stock_pickings(self, pickings, with_lines=False):
Expand Down Expand Up @@ -1040,7 +1040,7 @@ def set_lot(
product = selected_line.product_id
lot = search.lot_from_scan(lot_name, products=product)
if not lot:
lot = self.env["stock.production.lot"].create(
lot = self.env["stock.lot"].create(
self._create_lot_values(product, lot_name)
)
selected_line.lot_id = lot.id
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def set_quantity__cancel_action(self, picking_id, selected_line_id):
picking, selected_line, message=message
)
if selected_line.exists():
if selected_line.product_uom_qty:
if selected_line.reserved_uom_qty:
stock = self._actions_for("stock")
stock.unmark_move_line_as_picked(selected_line)
else:
Expand Down Expand Up @@ -1256,7 +1256,7 @@ def process_without_pack(self, picking_id, selected_line_id, quantity):
return self._response_for_set_destination(picking, selected_line)

def _post_line(self, selected_line):
selected_line.product_uom_qty = selected_line.qty_done
selected_line.reserved_uom_qty = selected_line.qty_done
if (
selected_line.picking_id.is_shopfloor_created
and self.work.menu.allow_return
Expand All @@ -1271,7 +1271,7 @@ def _post_line(self, selected_line):
self._auto_post_line(selected_line)

def _post_shopfloor_created_line(self, selected_line):
selected_line.product_uom_qty = selected_line.qty_done
selected_line.reserved_uom_qty = selected_line.qty_done
selected_line.picking_id.with_context(cancel_backorder=True)._action_done()
return self._response_for_select_document(

Check warning on line 1276 in shopfloor_reception/services/reception.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_reception/services/reception.py#L1274-L1276

Added lines #L1274 - L1276 were not covered by tests
message=self.msg_store.transfer_done_success(selected_line.picking_id)
Expand All @@ -1287,13 +1287,13 @@ def _auto_post_line(self, selected_line):
# in Odoo when move lines are created manually (setting)
lines_with_qty_todo = selected_line.move_id.move_line_ids.filtered(
lambda line: line.state not in ("cancel", "done")
and line.product_uom_qty > 0
and line.reserved_uom_qty > 0
)
move = selected_line.move_id
lock = self._actions_for("lock")
lock.for_update(move)
if lines_with_qty_todo:
lines_with_qty_todo.product_uom_qty = 0
lines_with_qty_todo.reserved_uom_qty = 0

move_quantity = move.product_uom._compute_quantity(
move.product_uom_qty, selected_line.product_uom_id
Expand All @@ -1317,7 +1317,7 @@ def _auto_post_line(self, selected_line):
move_quantity = move.product_uom._compute_quantity(
move.product_uom_qty, line[0].product_uom_id
)
line.product_uom_qty = move_quantity
line.reserved_uom_qty = move_quantity
move._recompute_state()
new_move.extract_and_action_done()

Expand Down
18 changes: 8 additions & 10 deletions shopfloor_reception/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">Shopfloor Reception</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2daa340b0e627a464975665796f422f9792c329d73389a28e995a4a0c11234a2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/wms/tree/14.0/shopfloor_reception"><img alt="OCA/wms" src="https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-shopfloor_reception"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/wms&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/wms/tree/16.0/shopfloor_reception"><img alt="OCA/wms" src="https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_reception"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/wms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Shopfloor implementation of the reception scenario.
Allows to receive products and create the proper packs for each logistic unit.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -394,7 +393,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/wms/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/wms/issues/new?body=module:%20shopfloor_reception%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/wms/issues/new?body=module:%20shopfloor_reception%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -412,20 +411,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Juan Miguel Sánchez Arce &lt;<a class="reference external" href="mailto:juan.sanchez&#64;camptocamp.com">juan.sanchez&#64;camptocamp.com</a>&gt;</li>
<li>Jacques-Etienne Baudoux (BCIM) &lt;<a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a>&gt;</li>
<li>Michael Tietz (MT Software) &lt;<a class="reference external" href="mailto:mtietz&#64;mt-software.de">mtietz&#64;mt-software.de</a>&gt;</li>
<li>Souheil Bejaoui &lt;<a class="reference external" href="mailto:souheil.bejaoui&#64;acsone.eu">souheil.bejaoui&#64;acsone.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/mmequignon"><img alt="mmequignon" src="https://github.com/mmequignon.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/JuMiSanAr"><img alt="JuMiSanAr" src="https://github.com/JuMiSanAr.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/wms/tree/14.0/shopfloor_reception">OCA/wms</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/wms/tree/16.0/shopfloor_reception">OCA/wms</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions shopfloor_reception/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2020 Camptocamp SA (http://www.camptocamp.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

# pylint: disable=missing-return

from odoo import fields

Expand All @@ -23,7 +23,7 @@ def _create_lot(cls, **kwargs):
"company_id": cls.env.company.id,
}
vals.update(kwargs)
return cls.env["stock.production.lot"].create(vals)
return cls.env["stock.lot"].create(vals)

@classmethod
def _add_package(cls, picking):
Expand Down Expand Up @@ -67,7 +67,7 @@ def _data_for_pickings_with_line(self, pickings):

def _data_for_picking_with_moves(self, picking, with_progress=True):
picking_data = self._data_for_picking(picking, with_progress)
moves_data = self._data_for_moves(picking.move_lines)
moves_data = self._data_for_moves(picking.move_ids)
picking_data.update({"moves": moves_data})
return picking_data

Expand Down
13 changes: 9 additions & 4 deletions shopfloor_reception/tests/reception_return_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def setUpClass(cls):
super().setUpClass()
# In order to have the `picking_type_reception_demo` picking_type
# on returned pickings and moves
cls.stock_manager = cls.env.ref("stock.group_stock_manager").users[0]
cls.reception_type = cls.env.ref(
"shopfloor_reception.picking_type_reception_demo"
)
Expand Down Expand Up @@ -74,7 +75,7 @@ def _add_package_to_order(cls, order):
for line in order.order_line:
product = line.product_id
packaging = packagings.filtered(lambda p: p.product_id == product)
line.product_packaging = packaging
line.product_packaging_id = packaging

@classmethod
def deliver(cls, pickings):
Expand All @@ -85,7 +86,7 @@ def deliver(cls, pickings):
if not ready_picking:
break
for line in ready_picking.move_line_ids:
line.qty_done = line.product_qty
line.qty_done = line.reserved_uom_qty
ready_picking._action_done()

@classmethod
Expand All @@ -95,7 +96,9 @@ def partial_deliver(cls, picking, qty_done):
if not action_data or action_data is True:
return picking.browse()

Check warning on line 97 in shopfloor_reception/tests/reception_return_common.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_reception/tests/reception_return_common.py#L97

Added line #L97 was not covered by tests
backorder_wizard = Form(
cls.env["stock.backorder.confirmation"].with_context(action_data["context"])
cls.env["stock.backorder.confirmation"].with_context(
**action_data["context"]
)
).save()
backorder_wizard.process()
return cls.env["stock.picking"].search([("backorder_id", "=", picking.id)])
Expand Down Expand Up @@ -141,7 +144,9 @@ def _add_stock_to_product(cls, product, location, qty):
"location_id": location.id,
"inventory_quantity": qty,
}
cls.env["stock.quant"].sudo().with_context(inventory_mode=True).create(values)
cls.env["stock.quant"].with_user(cls.stock_manager).with_context(
inventory_mode=True
).create(values)._apply_inventory()
cls.cache_existing_record_ids()

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions shopfloor_reception/tests/test_return_reception_done.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_set_done_full_qty_done(self):
)

def test_set_done_partial_qty_done(self):
self.assertEqual(self.selected_move_line.product_uom_qty, 20.0)
self.assertEqual(self.selected_move_line.reserved_uom_qty, 20.0)
self._set_quantity_done(qty_done=10.0)
response = self._dispatch()
# As this is a return created by the app, no backorder is created,
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_set_done_partial_qty_done(self):
)
selected_line_2 = self.get_new_move_lines()
# Ensure that the max qty to return is 10.0
self.assertEqual(selected_line_2.product_uom_qty, 10.0)
self.assertEqual(selected_line_2.reserved_uom_qty, 10.0)
# Set qty done == 10.0
params = {
"picking_id": return_picking_2.id,
Expand Down
2 changes: 1 addition & 1 deletion shopfloor_reception/tests/test_return_scan_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_scan_partial_delivered_order(self):
self._enable_allow_return()
delivery = self.create_delivery()
backorder = self.partial_deliver(delivery, 10)
self.assertEqual(backorder.move_lines.product_qty, 10)
self.assertEqual(backorder.move_ids.product_qty, 10)
response = self.service.dispatch(
"scan_document", params={"barcode": self.order.name}
)
Expand Down
Loading

0 comments on commit 218e349

Please sign in to comment.