Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
051ba74
[ADD] mrp_subcontracting_skip_no_negative
AungKoKoLin1997 May 1, 2023
aa900fc
[IMP] add quant check after all process is done
AungKoKoLin1997 Sep 29, 2023
f5ed23f
[UPD] Update mrp_subcontracting_skip_no_negative.pot
Nov 10, 2023
55d2af9
[BOT] post-merge updates
OCA-git-bot Nov 10, 2023
97f4d70
Added translation using Weblate (Italian)
mymage Nov 13, 2023
a54ac97
Translated using Weblate (Italian)
mymage Nov 14, 2023
edba17a
Translated using Weblate (Italian)
mymage Nov 16, 2023
5568d22
[FIX] mrp_subcontracting_skip_no_negative: consider move with multipl…
JordiMForgeFlow Jan 18, 2024
2292cdd
[BOT] post-merge updates
OCA-git-bot Mar 2, 2024
8d137ee
[IMP] mrp_subcontracting_skip_no_negative: Show negative stock error …
victoralmau Oct 23, 2024
dc1c572
[UPD] Update mrp_subcontracting_skip_no_negative.pot
Nov 5, 2024
04e225a
[BOT] post-merge updates
OCA-git-bot Nov 5, 2024
c4a9606
Update translation files
weblate Nov 5, 2024
6464177
Translated using Weblate (Italian)
mymage Nov 8, 2024
951fdff
[IMP] mrp_subcontracting_skip_no_negative: pre-commit auto fixes
david-s73 Jan 13, 2025
825e500
[MIG] mrp_subcontracting_skip_no_negative: Migration to 17.0
david-s73 Jan 13, 2025
8f97d7f
[17.0][FIX] mrp_subcontracting_skip_no_negative: backorder
Raul-S73 May 22, 2025
541f249
[UPD] Update mrp_subcontracting_skip_no_negative.pot
Oct 28, 2025
c19f032
[BOT] post-merge updates
OCA-git-bot Oct 28, 2025
8966060
[MIG] mrp_subcontracting_skip_no_negative: Migration to 18.0
AungKoKoLin1997 Dec 4, 2025
156ed93
[IMP] mrp_subcontracting_skip_negative: remove unrelated code with no…
AungKoKoLin1997 Dec 4, 2025
c5d2942
[FIX][IMP] mrp_subcontracting_skip_no_negative: fix creating backorde…
AungKoKoLin1997 Dec 10, 2025
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
111 changes: 111 additions & 0 deletions mrp_subcontracting_skip_no_negative/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
===================================
MRP Subcontracting Skip No Negative
===================================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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/18.0/mrp_subcontracting_skip_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-18-0/manufacture-18-0-mrp_subcontracting_skip_no_negative
: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/manufacture&target_branch=18.0
:alt: Try me on Runboat

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

This module skips the negative quantity check, provided by
stock_no_negative, for subcontracting receipts.

Background:
-----------

Odoo processes subcontracting receipt in the order of:

1. Transfer of the subcontracted product from the subcontractor location
to the internal location. 2. Production of the subcontracted product in
the subcontractor location.

This sequence does not represent the reality where production is done
before transfer, and therefore the above Step 1 would fail with negative
stock in the subcontractor location, when stock_no_negative is
installed, unless the product/location is configured to allow negative
stock.

ref. https://github.com/odoo/odoo/pull/75065

**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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_skip_no_negative%0Aversion:%2018.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
-------

* Quartile

Contributors
------------

- `Quartile <https://www.quartile.co>`__:

- Aung Ko Ko Lin

- `Tecnativa <https://www.tecnativa.com>`__:

- Víctor Martínez

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-yostashiro| image:: https://github.com/yostashiro.png?size=40px
:target: https://github.com/yostashiro
:alt: yostashiro
.. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px
:target: https://github.com/aungkokolin1997
:alt: aungkokolin1997

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

|maintainer-yostashiro| |maintainer-aungkokolin1997|

This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/18.0/mrp_subcontracting_skip_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_skip_no_negative/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions mrp_subcontracting_skip_no_negative/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "MRP Subcontracting Skip No Negative",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",
"category": "Manufacturing",
"depends": ["mrp_subcontracting", "stock_no_negative"],
"maintainers": ["yostashiro", "aungkokolin1997"],
"installable": True,
"auto_install": True,
}
43 changes: 43 additions & 0 deletions mrp_subcontracting_skip_no_negative/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_subcontracting_skip_no_negative
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-05 07:53+0000\n"
"PO-Revision-Date: 2024-11-05 08:53+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 3.0.1\n"

#. module: mrp_subcontracting_skip_no_negative
#: model:ir.model,name:mrp_subcontracting_skip_no_negative.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"

#. module: mrp_subcontracting_skip_no_negative
#: model:ir.model,name:mrp_subcontracting_skip_no_negative.model_stock_picking
msgid "Transfer"
msgstr "Transferencia"

#. module: mrp_subcontracting_skip_no_negative
#. odoo-python
#: code:addons/mrp_subcontracting_skip_no_negative/models/stock_move.py:0
#, python-format
msgid ""
"You cannot validate this stock operation because the stock level of the "
"component product '{name}' would become negative ({qty}) on the stock "
"location '{location}' and negative stock is not allowed for this product and/"
"or location."
msgstr ""
"No se puede validar esta operación de stock porque el nivel de stock del "
"producto componente '{name}' se volvería negativo ({qty}) en la ubicación de "
"stock '{location}' y no se permite stock negativo para este producto y/o "
"ubicación."
42 changes: 42 additions & 0 deletions mrp_subcontracting_skip_no_negative/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_subcontracting_skip_no_negative
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-11-08 09:35+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.6.2\n"

#. module: mrp_subcontracting_skip_no_negative
#: model:ir.model,name:mrp_subcontracting_skip_no_negative.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"

#. module: mrp_subcontracting_skip_no_negative
#: model:ir.model,name:mrp_subcontracting_skip_no_negative.model_stock_picking
msgid "Transfer"
msgstr "Trasferimento"

#. module: mrp_subcontracting_skip_no_negative
#. odoo-python
#: code:addons/mrp_subcontracting_skip_no_negative/models/stock_move.py:0
#, python-format
msgid ""
"You cannot validate this stock operation because the stock level of the "
"component product '{name}' would become negative ({qty}) on the stock "
"location '{location}' and negative stock is not allowed for this product and/"
"or location."
msgstr ""
"Non è possibile convalidare questa operazione di magazzino perché il livello "
"di magazzino del prodotto componente '{name}' diventerebbe negativo ({qty}) "
"nell'ubicazione di magazzino '{location}' e per questo prodotto e/o "
"posizione non è consentito un magazzino negativo."
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_subcontracting_skip_no_negative
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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_skip_no_negative
#: model:ir.model,name:mrp_subcontracting_skip_no_negative.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: mrp_subcontracting_skip_no_negative
#: model:ir.model,name:mrp_subcontracting_skip_no_negative.model_stock_picking
msgid "Transfer"
msgstr ""

#. module: mrp_subcontracting_skip_no_negative
#. odoo-python
#: code:addons/mrp_subcontracting_skip_no_negative/models/stock_move.py:0
#, python-format
msgid ""
"You cannot validate this stock operation because the stock level of the "
"component product '{name}' would become negative ({qty}) on the stock "
"location '{location}' and negative stock is not allowed for this product "
"and/or location."
msgstr ""
2 changes: 2 additions & 0 deletions mrp_subcontracting_skip_no_negative/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move
from . import stock_picking
21 changes: 21 additions & 0 deletions mrp_subcontracting_skip_no_negative/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Quartile (https://www.quartile.co)
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models


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

def _action_done(self, cancel_backorder=False):
moves_with_no_check = self.filtered(lambda x: x.is_subcontract).with_context(
skip_negative_qty_check=True
)
res = super(StockMove, moves_with_no_check)._action_done(
cancel_backorder=cancel_backorder
)
res += super(StockMove, self - moves_with_no_check)._action_done(
cancel_backorder=cancel_backorder
)
return res
44 changes: 44 additions & 0 deletions mrp_subcontracting_skip_no_negative/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2023 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models


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

def _action_done(self):
res = super()._action_done()
self._check_negative_quants_after_process()
return res

def _check_negative_quants_after_process(self):
product_ids = self.mapped("move_ids.product_id.id")
quants = self.env["stock.quant"].search(
[
("product_id", "in", product_ids),
]
)
quants.check_negative_qty()

def _get_moves_to_backorder(self):
self.ensure_one()
moves = super()._get_moves_to_backorder()
if self.env.context.get("skip_negative_qty_check"):
return moves.filtered(lambda x: x.is_subcontract)
return moves

def _create_backorder_picking(self):
self.ensure_one()
existing_backorder_picking = self.env["stock.picking"].search(
[("backorder_id", "=", self.id)]
)
existing_subcontract_moves = existing_backorder_picking.move_ids.filtered(
lambda x: x.is_subcontract
)
if (
self.move_ids.filtered(lambda x: x.state == "done" and x.is_subcontract)
and existing_subcontract_moves
):
return existing_backorder_picking
return super()._create_backorder_picking()
3 changes: 3 additions & 0 deletions mrp_subcontracting_skip_no_negative/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions mrp_subcontracting_skip_no_negative/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Quartile](https://www.quartile.co):
- Aung Ko Ko Lin
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez
18 changes: 18 additions & 0 deletions mrp_subcontracting_skip_no_negative/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This module skips the negative quantity check, provided by
stock_no_negative, for subcontracting receipts.

## Background:

Odoo processes subcontracting receipt in the order of:

1\. Transfer of the subcontracted product from the subcontractor
location to the internal location. 2. Production of the subcontracted
product in the subcontractor location.

This sequence does not represent the reality where production is done
before transfer, and therefore the above Step 1 would fail with negative
stock in the subcontractor location, when stock_no_negative is
installed, unless the product/location is configured to allow negative
stock.

ref. <https://github.com/odoo/odoo/pull/75065>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading