Skip to content

Commit

Permalink
Merge commit 'refs/pull/363/head' of github.com:OCA/wms into merge-br…
Browse files Browse the repository at this point in the history
…anch-2477-bscos-4243-d0a32794
  • Loading branch information
TDu committed Nov 3, 2023
2 parents 4a45e54 + 6bcc05f commit cf0c052
Show file tree
Hide file tree
Showing 19 changed files with 916 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_reception_screen_mrp_subcontracting/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,
)
79 changes: 79 additions & 0 deletions stock_reception_screen_mrp_subcontracting/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
==============================================================
Stock - Reception screen (Subcontract Productions integration)
==============================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/13.0/stock_reception_screen_mrp_subcontracting
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-13-0/wms-13-0-stock_reception_screen_mrp_subcontracting
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/285/13.0
:alt: Try me on Runbot

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

This module makes compatible the reception screen flow with subcontracted goods
(`mrp_subcontracting` module).

.. 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/wms/issues/new?body=module:%20stock_reception_screen_mrp_subcontracting%0Aversion:%2013.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

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

* Sébastien Alix <[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.

This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/13.0/stock_reception_screen_mrp_subcontracting>`_ 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 stock_reception_screen_mrp_subcontracting/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
20 changes: 20 additions & 0 deletions stock_reception_screen_mrp_subcontracting/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "Stock - Reception screen (Subcontract Productions integration)",
"summary": "Reception screen integrated with subcontracted productions.",
"version": "14.0.1.0.0",
"category": "Stock",
"license": "AGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/wms",
"depends": [
"mrp_subcontracting",
# OCA/wms
"stock_reception_screen",
],
"data": [],
"installable": True,
"auto_install": True,
"development_status": "Alpha",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_reception_screen_mrp_subcontracting
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_reception_screen_mrp_subcontracting
#: model:ir.model,name:stock_reception_screen_mrp_subcontracting.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""

#. module: stock_reception_screen_mrp_subcontracting
#: model:ir.model,name:stock_reception_screen_mrp_subcontracting.model_mrp_product_produce
msgid "Record Production"
msgstr ""

#. module: stock_reception_screen_mrp_subcontracting
#: model:ir.model,name:stock_reception_screen_mrp_subcontracting.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: stock_reception_screen_mrp_subcontracting
#: model:ir.model,name:stock_reception_screen_mrp_subcontracting.model_stock_reception_screen
msgid "Stock Reception Screen"
msgstr ""
3 changes: 3 additions & 0 deletions stock_reception_screen_mrp_subcontracting/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import mrp_production
from . import stock_picking
from . import stock_reception_screen
22 changes: 22 additions & 0 deletions stock_reception_screen_mrp_subcontracting/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models


class MrpProduction(models.Model):
_inherit = "mrp.production"

def _set_qty_producing(self):
# Inhibited during the call of 'stock.picking._action_done()' of
# 'mrp_subcontracting' addon.
if self.env.context.get("subcontracting_skip_action_done"):
return False
return super()._set_qty_producing()

def button_mark_done(self):
# Inhibited during the call of 'stock.picking._action_done()' of
# 'mrp_subcontracting' addon.
if self.env.context.get("subcontracting_skip_action_done"):
return False
return super().button_mark_done()
75 changes: 75 additions & 0 deletions stock_reception_screen_mrp_subcontracting/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models
from odoo.tools import float_compare


class StockPicking(models.Model):
_inherit = "stock.picking"

def _action_done(self):
# In std Odoo we are not supposed to split & validate moves
# independently in only one receipt, and Odoo assumes that there is
# only one move corresponding to a MO, so if we receive more qty than
# the expected one, Odoo will automatically update the MO produced qty
# with the quantity done of the move.
# But with the reception screen, as several moves could be created from
# the original one, we need to update this produced qty by grouping all
# moves sharing the same MO.
# Here we disable some std behavior with the 'subcontracting_skip_action_done'
# context key and we rewrite the business logic.
new_self = self
if any(picking._is_subcontract() for picking in self):
new_self = self.with_context(subcontracting_skip_action_done=True)
res = super(StockPicking, new_self)._action_done()
for picking in self.filtered(lambda p: p._is_subcontract()):
productions = picking.move_lines.move_orig_ids.production_id.filtered(
lambda p: p.state not in ("done", "cancel")
)[-1:]
for production in productions:
# Update the qty to produce as it is done in 'mrp_subcontracting'
# but we group all received moves sharing the same MO here.
moves = production.move_finished_ids.move_dest_ids.filtered(
lambda m: (
m.picking_id == picking
and not m._has_tracked_subcontract_components()
)
)
if not moves:
continue
quantity_done = sum(
move.product_uom._compute_quantity(
move.quantity_done, production.product_uom_id
)
for move in moves
)
received_more_qty = (
float_compare(
production.product_qty,
quantity_done,
precision_rounding=production.product_uom_id.rounding,
)
== -1
)
if received_more_qty:
change_qty = self.env["change.production.qty"].create(
{"mo_id": production.id, "product_qty": quantity_done}
)
change_qty.with_context(skip_activity=True).change_prod_qty()
production.qty_producing = quantity_done
production._set_qty_producing()

# Validate MO as it is done in 'mrp_subcontracting'
productions_to_done = (
picking._get_subcontracted_productions()._subcontracting_filter_to_done()
)
production_ids_backorder = []
if not self.env.context.get("cancel_backorder"):
production_ids_backorder = productions_to_done.filtered(
lambda mo: mo.state == "progress"
).ids
productions_to_done.with_context(
subcontract_move_id=True, mo_ids_to_backorder=production_ids_backorder
).button_mark_done()
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models


class StockReceptionScreen(models.Model):
_inherit = "stock.reception.screen"

def _split_move(self, move, qty):
# Overridden to remove the link between the move of finished product
# and the move to receive to not update the qty to produce on the MO
# with a partial received qty. That way we always keep the original qty
# to produce on the MO while having the received qty split among
# several moves in the receipt.
move_is_subcontract = move.is_subcontract
move_move_orig = move.move_orig_ids
if move_is_subcontract:
move.move_orig_ids = False
new_move = super()._split_move(move, qty)
if move_is_subcontract:
# Link the finished product move with the remaining move to process
new_move.move_orig_ids = move_move_orig
# Restore the link between the finished product move with the received one
move.move_orig_ids = move_move_orig
return new_move

def _validate_current_move(self):
# Overridden to automatically recheck availability each time a move
# is validated to reserve qties from the production for remaining moves
res = super()._validate_current_move()
if self.current_move_id.is_subcontract:
if self.picking_id.state not in ("cancel", "done"):
self.picking_id.action_assign()
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sébastien Alix <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module makes compatible the reception screen flow with subcontracted goods
(`mrp_subcontracting` module).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cf0c052

Please sign in to comment.