-
Notifications
You must be signed in to change notification settings - Fork 2
[5016][UPD] mrp_subcontracting_skip_no_negative #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kanda999
wants to merge
2
commits into
16.0
Choose a base branch
from
5016-upd-mrp_subcontracting_skip_no_negative
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,15 +6,15 @@ msgid "" | |
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 16.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "PO-Revision-Date: 2023-11-16 12:43+0000\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 4.17\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 | ||
|
|
@@ -25,3 +25,18 @@ msgstr "Movimento di magazzino" | |
| #: 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." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| * `Quartile <https://www.quartile.co>`__: | ||
|
|
||
| * Aung Ko Ko Lin | ||
|
|
||
| * `Tecnativa <https://www.tecnativa.com>`_: | ||
|
|
||
| * Víctor Martínez |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,11 @@ | |
|
|
||
| /* | ||
| :Author: David Goodger ([email protected]) | ||
| :Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ | ||
| :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z 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. | ||
|
|
@@ -274,7 +275,7 @@ | |
| margin-left: 2em ; | ||
| margin-right: 2em } | ||
|
|
||
| pre.code .ln { color: grey; } /* line numbers */ | ||
| pre.code .ln { color: gray; } /* 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 } | ||
|
|
@@ -300,7 +301,7 @@ | |
| span.pre { | ||
| white-space: pre } | ||
|
|
||
| span.problematic { | ||
| span.problematic, pre.problematic { | ||
| color: red } | ||
|
|
||
| span.section-subtitle { | ||
|
|
@@ -366,7 +367,7 @@ <h1 class="title">MRP Subcontracting Skip No Negative</h1> | |
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:be1748f4d86ee601f04fee6c3ecec9db99e0aff2f2628d99f01406f1a1e20cf5 | ||
| !! source digest: sha256:b4b59b86062f08db75f2e86b8b9fced861771da8483adf65c81e3a65c0ba1c79 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> | ||
| <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&target_branch=16.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 | ||
|
|
@@ -413,12 +414,18 @@ <h1>Contributors</h1> | |
| <li>Aung Ko Ko Lin</li> | ||
| </ul> | ||
| </li> | ||
| <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul> | ||
| <li>Víctor Martínez</li> | ||
| </ul> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| <div class="section" id="maintainers"> | ||
| <h1>Maintainers</h1> | ||
| <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> | ||
|
|
||
98 changes: 71 additions & 27 deletions
98
mrp_subcontracting_skip_no_negative/tests/test_mrp_subcontracting_skip_no_negative.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,94 @@ | ||
| # Copyright 2023 Quartile Limited | ||
| # Copyright 2024 Tecnativa - Víctor Martínez | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
|
||
| from odoo.exceptions import ValidationError | ||
| from odoo.tests import Form | ||
| from odoo.tools import mute_logger | ||
|
|
||
| from odoo.addons.mrp_subcontracting.tests.common import TestMrpSubcontractingCommon | ||
|
|
||
|
|
||
| class TestMrpSubcontractingSkipNoNegative(TestMrpSubcontractingCommon): | ||
| 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") | ||
| picking_form.partner_id = self.subcontractor_partner1 | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.env = cls.env( | ||
| context=dict( | ||
| cls.env.context, | ||
| test_stock_no_negative=True, | ||
| ) | ||
| ) | ||
| picking_form = Form(cls.env["stock.picking"]) | ||
| picking_form.picking_type_id = cls.env.ref("stock.picking_type_in") | ||
| picking_form.partner_id = cls.subcontractor_partner1 | ||
| with picking_form.move_ids_without_package.new() as move: | ||
| move.product_id = self.finished | ||
| move.product_id = cls.finished | ||
| move.product_uom_qty = 1 | ||
| subcontracting_receipt = picking_form.save() | ||
| subcontracting_receipt = subcontracting_receipt.with_context( | ||
| test_stock_no_negative=True | ||
| cls.subcontracting_receipt = picking_form.save() | ||
|
|
||
| def _create_stock_quant(self, product, qty): | ||
| self.env["stock.quant"].create( | ||
| { | ||
| "product_id": product.id, | ||
| "location_id": self.subcontractor_partner1.property_stock_subcontractor.id, | ||
| "quantity": qty, | ||
| } | ||
| ) | ||
| subcontracting_receipt.action_confirm() | ||
| self.assertEqual(subcontracting_receipt.state, "assigned") | ||
| immediate_wizard = subcontracting_receipt.button_validate() | ||
|
|
||
| @mute_logger("odoo.models.unlink") | ||
| def test_mrp_subcontracting_skip_no_negative_01(self): | ||
| self.subcontracting_receipt.action_confirm() | ||
| self.assertEqual(self.subcontracting_receipt.state, "assigned") | ||
| immediate_wizard = self.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( | ||
| **immediate_wizard["context"] | ||
| ) | ||
| ).save() | ||
| with self.assertRaises(ValidationError): | ||
| # Component1 error | ||
| with self.assertRaises(ValidationError) as e1: | ||
| immediate_wizard_form.process() | ||
| self.assertIn("Component1", str(e1.exception)) | ||
| # Create comp1 stock, and try subcontracting receipt process. | ||
| self._create_stock_quant(self.comp1, 10) | ||
| # Component2 error | ||
| with self.assertRaises(ValidationError) as e2: | ||
| immediate_wizard_form.process() | ||
| self.assertIn("Component2", str(e2.exception)) | ||
| # Create comp2 stock, and subcontracting receipt should now be successful. | ||
| self._create_stock_quant(self.comp2, 10) | ||
| immediate_wizard_form.process() | ||
| self.assertEqual(self.subcontracting_receipt.state, "done") | ||
|
|
||
| # Create component stock, and subcontracting receipt should now be successful. | ||
| self.env["stock.quant"].create( | ||
| { | ||
| "product_id": self.comp1.id, | ||
| "location_id": self.subcontractor_partner1.property_stock_subcontractor.id, | ||
| "quantity": 10, | ||
| } | ||
| ) | ||
| self.env["stock.quant"].create( | ||
| { | ||
| "product_id": self.comp2.id, | ||
| "location_id": self.subcontractor_partner1.property_stock_subcontractor.id, | ||
| "quantity": 10, | ||
| } | ||
| def test_mrp_subcontracting_skip_no_negative_03(self): | ||
| self._create_stock_quant(self.comp1, 10) | ||
| self._create_stock_quant(self.comp2, 10) | ||
| self.subcontracting_receipt.action_confirm() | ||
| self.assertEqual(self.subcontracting_receipt.state, "assigned") | ||
| immediate_wizard = self.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( | ||
| **immediate_wizard["context"] | ||
| ) | ||
| ).save() | ||
| immediate_wizard_form.process() | ||
| self.assertEqual(self.subcontracting_receipt.state, "done") | ||
|
|
||
| def test_mrp_subcontracting_skip_no_negative_04(self): | ||
| self.subcontractor_partner1.property_stock_subcontractor.allow_negative_stock = ( | ||
| True | ||
| ) | ||
| self.subcontracting_receipt.action_confirm() | ||
| self.assertEqual(self.subcontracting_receipt.state, "assigned") | ||
| immediate_wizard = self.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( | ||
| **immediate_wizard["context"] | ||
| ) | ||
| ).save() | ||
| immediate_wizard_form.process() | ||
| self.assertEqual(subcontracting_receipt.state, "done") | ||
| self.assertEqual(self.subcontracting_receipt.state, "done") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the current code doesn't handle the case well where partial receipt is processed for a picking which only contains subcontracted products.