[MIG] mrp_subcontracting_skip_no_negative: Migration to 14.0

TT50668
This commit is contained in:
Víctor Martínez
2024-08-30 16:51:16 +02:00
parent 134769717d
commit f9cdc192e1
9 changed files with 31 additions and 37 deletions

View File

@@ -17,13 +17,13 @@ MRP Subcontracting Skip No Negative
: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_skip_no_negative
:target: https://github.com/OCA/manufacture/tree/14.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-16-0/manufacture-16-0-mrp_subcontracting_skip_no_negative
:target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-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=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=14.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -57,7 +57,7 @@ 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:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_skip_no_negative%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.
@@ -89,6 +89,6 @@ 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/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_skip_no_negative>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/14.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.

View File

@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "MRP Subcontracting Skip No Negative",
"version": "16.0.1.0.1",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Quartile Limited, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",

View File

@@ -1,2 +1 @@
from . import stock_move
from . import stock_picking

View File

@@ -8,6 +8,10 @@ class StockMove(models.Model):
_inherit = "stock.move"
def _action_done(self, cancel_backorder=False):
# It is necessary to apply the key context to skip the error in the
# subcontracting process
if self.env.context.get("subcontract_move_id"):
self = self.with_context(skip_negative_qty_check=True)
moves_with_no_check = self.filtered(lambda x: x.is_subcontract).with_context(
skip_negative_qty_check=True
)

View File

@@ -1,22 +0,0 @@
# Copyright 2023 Quartile Limited
# 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()

View File

@@ -368,7 +368,7 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:be1748f4d86ee601f04fee6c3ecec9db99e0aff2f2628d99f01406f1a1e20cf5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/manufacture/tree/16.0/mrp_subcontracting_skip_no_negative"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_skip_no_negative"><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/manufacture&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><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/manufacture/tree/14.0/mrp_subcontracting_skip_no_negative"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_subcontracting_skip_no_negative"><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/manufacture&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>This module skips the negative quantity check, provided by stock_no_negative, for
subcontracting receipts.</p>
<div class="section" id="background">
@@ -393,7 +393,7 @@ is installed, unless the product/location is configured to allow negative stock.
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/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/manufacture/issues/new?body=module:%20mrp_subcontracting_skip_no_negative%0Aversion:%2016.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/manufacture/issues/new?body=module:%20mrp_subcontracting_skip_no_negative%0Aversion:%2014.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">
@@ -422,7 +422,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<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>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_skip_no_negative">OCA/manufacture</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/14.0/mrp_subcontracting_skip_no_negative">OCA/manufacture</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>

View File

@@ -8,6 +8,16 @@ from odoo.addons.mrp_subcontracting.tests.common import TestMrpSubcontractingCom
class TestMrpSubcontractingSkipNoNegative(TestMrpSubcontractingCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(
context=dict(
cls.env.context,
test_stock_no_negative=True,
)
)
def test_mrp_subcontracting_skip_no_negative(self):
picking_form = Form(self.env["stock.picking"])
picking_form.picking_type_id = self.env.ref("stock.picking_type_in")
@@ -16,12 +26,9 @@ class TestMrpSubcontractingSkipNoNegative(TestMrpSubcontractingCommon):
move.product_id = self.finished
move.product_uom_qty = 1
subcontracting_receipt = picking_form.save()
subcontracting_receipt = subcontracting_receipt.with_context(
test_stock_no_negative=True
)
subcontracting_receipt.action_confirm()
self.assertEqual(subcontracting_receipt.state, "assigned")
immediate_wizard = subcontracting_receipt.button_validate()
immediate_wizard = subcontracting_receipt.sudo().button_validate()
self.assertEqual(immediate_wizard.get("res_model"), "stock.immediate.transfer")
immediate_wizard_form = Form(
self.env[immediate_wizard["res_model"]].with_context(
@@ -30,7 +37,6 @@ class TestMrpSubcontractingSkipNoNegative(TestMrpSubcontractingCommon):
).save()
with self.assertRaises(ValidationError):
immediate_wizard_form.process()
# Create component stock, and subcontracting receipt should now be successful.
self.env["stock.quant"].create(
{

View File

@@ -0,0 +1 @@
../../../../mrp_subcontracting_skip_no_negative

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)