Skip to content
Closed
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
90 changes: 90 additions & 0 deletions mrp_subcontracting_no_negative/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
===========================================
MRP Subcontracting (no negative components)
===========================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_no_negative
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_no_negative
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/16.0
:alt: Try me on Runbot

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

Disallow negative stock levels in subcontractor locations.

In standard Odoo it is allowed to validate a subcontractor receipt to get
the finished products even if the components haven't been sent to the
subcontractor. This module prevents this with an error message.

.. 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/manufacture/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/manufacture/issues/new?body=module:%20mrp_subcontracting_no_negative%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.

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.

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

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

|maintainer-sebalix|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mrp_subcontracting_no_negative/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions mrp_subcontracting_no_negative/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "MRP Subcontracting (no negative components)",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["sebalix"],
"summary": "Disallow negative stock levels in subcontractor locations.",
"website": "https://github.com/OCA/manufacture",
"category": "Manufacturing",
"depends": [
"mrp_subcontracting",
],
"data": [],
"installable": True,
"auto_install": True,
"application": False,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_subcontracting_no_negative
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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: mrp_subcontracting_no_negative
#: model:ir.model,name:mrp_subcontracting_no_negative.model_stock_picking
msgid "Transfer"
msgstr ""

#. module: mrp_subcontracting_no_negative
#: code:addons/mrp_subcontracting_no_negative/models/stock_picking.py:0
#, python-format
msgid "Unable to reserve components in the location %s."
msgstr ""
2 changes: 2 additions & 0 deletions mrp_subcontracting_no_negative/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_picking
from . import stock_move
22 changes: 22 additions & 0 deletions mrp_subcontracting_no_negative/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, exceptions, models


class StockMove(models.Model):
_inherit = "stock.move"

def _action_record_components(self):
self.ensure_one()
production = self._get_subcontract_production()[-1:]
if production.reservation_state != "assigned":
production.action_assign()
# Block the reception if components could not be reserved
# NOTE: this also avoids the creation of negative quants
if production.reservation_state != "assigned":
raise exceptions.UserError(
_("Unable to reserve components in the location %s.")
% (production.location_src_id.name)
)
return super()._action_record_components()
24 changes: 24 additions & 0 deletions mrp_subcontracting_no_negative/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, exceptions, models


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

def action_record_components(self):
self.ensure_one()
if self._is_subcontract():
# Try to reserve the components
for production in self._get_subcontract_production():
if production.reservation_state != "assigned":
production.action_assign()
# Block the reception if components could not be reserved
# NOTE: this also avoids the creation of negative quants
if production.reservation_state != "assigned":
raise exceptions.UserError(
_("Unable to reserve components in the location %s.")
% (production.location_src_id.name)
)
return super().action_record_components()
1 change: 1 addition & 0 deletions mrp_subcontracting_no_negative/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sébastien Alix <[email protected]>
5 changes: 5 additions & 0 deletions mrp_subcontracting_no_negative/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Disallow negative stock levels in subcontractor locations.

In standard Odoo it is allowed to validate a subcontractor receipt to get
the finished products even if the components haven't been sent to the
subcontractor. This module prevents this with an error message.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading