-
-
Notifications
You must be signed in to change notification settings - Fork 542
[16.0][ADD] quality_control_stock_oca: automatic scrap creation on Inspection failure #1611
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
Open
quirino95
wants to merge
2
commits into
OCA:16.0
Choose a base branch
from
PyTech-SRL:16.0-receipts_inspection_failure
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.
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
.. image:: https://odoo-community.org/readme-banner-image | ||
:target: https://odoo-community.org/get-involved?utm_source=readme | ||
:alt: Odoo Community Association | ||
|
||
============================= | ||
Quality control - Stock (OCA) | ||
============================= | ||
|
@@ -17,7 +13,7 @@ Quality control - Stock (OCA) | |
.. |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/license-AGPL--3-blue.png | ||
.. |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 | ||
|
@@ -35,6 +31,10 @@ Quality control - Stock (OCA) | |
This module defines triggers that creates inspections when stock moves are done. | ||
|
||
It also adds some shortcuts on picking and lots to these inspections. | ||
Activating the "Remind Quality Control" flag on products, if inspections are not done (successfully or unsuccessfully), on picking confirmation a reminder popup appears. | ||
Activating "Scrap Automatically" flag on products, if inspections fail, picking: | ||
- Will be automatic validated if every product in picking has the flag checked; | ||
- On validation, will generate scraps automatically for every product with the flag checked and whose inspection has failed; | ||
|
||
**Table of contents** | ||
|
||
|
@@ -99,6 +99,10 @@ Contributors | |
* Aung Ko Ko Lin | ||
* Yoshi Tashiro | ||
|
||
* `PyTech <https://www.pytech.it>`_: | ||
|
||
* Quirino Leone <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
remind_qc = fields.Boolean( | ||
string="Remind Quality Control", | ||
help="If selected, notify to perform Quality Control on this product when scheduled", | ||
) | ||
|
||
auto_scrap = fields.Boolean( | ||
string="Scrap Automatically", | ||
help="If selected, automatically scraps this product when inspections fail", | ||
) |
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 @@ | ||
manufacture https://github.com/OCA/manufacture refs/pull/1584/head bdd2b3719bb2c71e064ae646745c74e7f9c86e95 |
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 |
---|---|---|
|
@@ -12,3 +12,7 @@ | |
|
||
* Aung Ko Ko Lin | ||
* Yoshi Tashiro | ||
|
||
* `PyTech <https://www.pytech.it>`_: | ||
|
||
* Quirino Leone <[email protected]> |
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 @@ | ||
This module defines triggers that creates inspections when stock moves are done. | ||
|
||
It also adds some shortcuts on picking and lots to these inspections. | ||
Activating the "Remind Quality Control" flag on products, if inspections are not done (successfully or unsuccessfully), on picking confirmation a reminder popup appears. | ||
Activating "Scrap Automatically" flag on products, if inspections fail, picking: | ||
- Will be automatic validated if every product in picking has the flag checked; | ||
- On validation, will generate scraps automatically for every product with the flag checked and whose inspection has failed; |
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,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_qc_check_wizard,access_qc_check_wizard,model_qc_check_wizard,stock.group_stock_user,1,1,1,1 |
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_quality_control_stock | ||
from . import test_quality_control_stock, test_qc_check_wizard |
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,55 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestQCCheckWizard(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.wiz_model = cls.env["qc.check.wizard"] | ||
|
||
cls.test_location = cls.env.ref("stock.stock_location_stock") | ||
cls.product = cls.env["product.product"].create( | ||
{"name": "Test Product", "type": "product"} | ||
) | ||
cls.picking_type = cls.env["stock.picking.type"].create( | ||
{ | ||
"name": "Test Operation Type", | ||
"sequence_code": "1", | ||
"code": "incoming", | ||
} | ||
) | ||
|
||
cls.stock_picking1 = cls.env["stock.picking"].create( | ||
{ | ||
"location_id": cls.test_location.id, | ||
"location_dest_id": cls.test_location.id, | ||
"picking_type_id": cls.picking_type.id, | ||
"move_ids": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"product_id": 1, | ||
"product_uom_qty": 1, | ||
"product_uom": 1, | ||
"name": "Test Product", | ||
"location_id": cls.test_location.id, | ||
"location_dest_id": cls.test_location.id, | ||
}, | ||
) | ||
], | ||
} | ||
) | ||
|
||
def test_qc_check_wizard(self): | ||
wizard = self.wiz_model.create({"stock_picking_ids": self.stock_picking1.ids}) | ||
self.assertTrue(wizard.stock_picking_ids) | ||
|
||
move1 = self.stock_picking1.move_ids[0] | ||
move1.quantity_done = 1 | ||
|
||
wizard.action_complete_inspections() | ||
self.assertNotEqual(self.stock_picking1.state, "done") | ||
|
||
wizard.action_skip_inspections() | ||
self.assertEqual(self.stock_picking1.state, "done") |
Oops, something went wrong.
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.
Question: I see in description it says: "Moves should be done once set inspection as "failed" (so the "validation" should be automatic).", So I think whenever inspections are done and failed, Validation has to be completed (i.e. Pickings are in
Done
state) and also create scrap if any one of the products has 'scrap automatically' asTrue
in a receipt- Is my understanding right?If so, here mentioning validation is automatic only if
every product
has checked withscrap automatically
is valid?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.
Yes, is valid. This is a way to keep the default behavior, but also a chance to have a different behavior (checking flag
auto_scrap
) to speed up picking validation.Uh oh!
There was an error while loading. Please reload this page.
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.
Thank you for clarification. Implementation works intact for success scenarios but with respect to failed inspections after latest fix observed some improper behaviour as commented below. Could not figure out yet what makes this trigger of inspection when
auto_scrap
is checked and inspection is failed.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.
Please see comment below