diff --git a/quality_control_stock_oca/README.rst b/quality_control_stock_oca/README.rst index 8dd18bdec..8da328bf3 100644 --- a/quality_control_stock_oca/README.rst +++ b/quality_control_stock_oca/README.rst @@ -7,7 +7,7 @@ Quality control - Stock (OCA) !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:6a7081017d1705e47f1c601056c9db6f3dd3368a22519f03457e7f239cf92505 + !! source digest: sha256:7430252681826a0a0f9a869194458e38ac20900898f0f8ff40422f13702695ee !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Quality control - Stock (OCA) :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/15.0/quality_control_stock_oca + :target: https://github.com/OCA/manufacture/tree/16.0/quality_control_stock_oca :alt: OCA/manufacture .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-quality_control_stock_oca + :target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-quality_control_stock_oca :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=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -48,7 +48,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. 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 `_ project on GitHub. +This module is part of the `OCA/manufacture `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/quality_control_stock_oca/__manifest__.py b/quality_control_stock_oca/__manifest__.py index 0756c7d37..dc089df62 100644 --- a/quality_control_stock_oca/__manifest__.py +++ b/quality_control_stock_oca/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Quality control - Stock (OCA)", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "category": "Quality control", "license": "AGPL-3", "author": "OdooMRP team, AvanzOSC, Serv. Tecnol. Avanzados - Pedro M. Baeza, " @@ -16,6 +16,7 @@ "views/qc_inspection_view.xml", "views/stock_picking_view.xml", "views/stock_production_lot_view.xml", + "views/qc_trigger_view.xml", ], "post_init_hook": "post_init_hook", "installable": True, diff --git a/quality_control_stock_oca/i18n/quality_control_stock_oca.pot b/quality_control_stock_oca/i18n/quality_control_stock_oca.pot index 6450c915a..64ae11599 100644 --- a/quality_control_stock_oca/i18n/quality_control_stock_oca.pot +++ b/quality_control_stock_oca/i18n/quality_control_stock_oca.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" diff --git a/quality_control_stock_oca/models/qc_inspection.py b/quality_control_stock_oca/models/qc_inspection.py index 39a96d59a..5e85afd3e 100644 --- a/quality_control_stock_oca/models/qc_inspection.py +++ b/quality_control_stock_oca/models/qc_inspection.py @@ -13,7 +13,7 @@ class QcInspection(models.Model): comodel_name="stock.picking", compute="_compute_picking", store=True ) lot_id = fields.Many2one( - comodel_name="stock.production.lot", compute="_compute_lot", store=True + comodel_name="stock.lot", compute="_compute_lot", store=True ) def object_selection_values(self): @@ -22,7 +22,7 @@ class QcInspection(models.Model): [ ("stock.picking", "Picking List"), ("stock.move", "Stock Move"), - ("stock.production.lot", "Lot/Serial Number"), + ("stock.lot", "Lot/Serial Number"), ] ) return result @@ -35,8 +35,6 @@ class QcInspection(models.Model): inspection.picking_id = inspection.object_id.picking_id elif inspection.object_id._name == "stock.picking": inspection.picking_id = inspection.object_id - elif inspection.object_id._name == "stock.move.line": - inspection.picking_id = inspection.object_id.picking_id @api.depends("object_id") def _compute_lot(self): @@ -49,15 +47,13 @@ class QcInspection(models.Model): for inspection in self: if inspection.object_id: - if inspection.object_id._name == "stock.move.line": - inspection.lot_id = inspection.object_id.lot_id - elif inspection.object_id._name == "stock.move": + if inspection.object_id._name == "stock.move": inspection.lot_id = first( move_lines.filtered( lambda line: line.move_id == inspection.object_id ) ).lot_id - elif inspection.object_id._name == "stock.production.lot": + elif inspection.object_id._name == "stock.lot": inspection.lot_id = inspection.object_id @api.depends("object_id") @@ -67,25 +63,18 @@ class QcInspection(models.Model): for inspection in self.filtered("object_id"): if inspection.object_id._name == "stock.move": inspection.product_id = inspection.object_id.product_id - elif inspection.object_id._name == "stock.move.line": - inspection.product_id = inspection.object_id.product_id - elif inspection.object_id._name == "stock.production.lot": + elif inspection.object_id._name == "stock.lot": inspection.product_id = inspection.object_id.product_id return res @api.onchange("object_id") def onchange_object_id(self): - if self.object_id: - if self.object_id._name == "stock.move": - self.qty = self.object_id.product_qty - elif self.object_id._name == "stock.move.line": - self.qty = self.object_id.product_qty + if self.object_id._name == "stock.move": + self.qty = self.object_id.product_qty def _prepare_inspection_header(self, object_ref, trigger_line): res = super()._prepare_inspection_header(object_ref, trigger_line) # Fill qty when coming from pack operations - if object_ref and object_ref._name == "stock.move.line": - res["qty"] = object_ref.product_qty if object_ref and object_ref._name == "stock.move": res["qty"] = object_ref.product_uom_qty return res @@ -98,5 +87,5 @@ class QcInspectionLine(models.Model): comodel_name="stock.picking", related="inspection_id.picking_id", store=True ) lot_id = fields.Many2one( - comodel_name="stock.production.lot", related="inspection_id.lot_id", store=True + comodel_name="stock.lot", related="inspection_id.lot_id", store=True ) diff --git a/quality_control_stock_oca/models/stock_picking.py b/quality_control_stock_oca/models/stock_picking.py index 59cf813ea..e99a0d8d6 100644 --- a/quality_control_stock_oca/models/stock_picking.py +++ b/quality_control_stock_oca/models/stock_picking.py @@ -64,7 +64,7 @@ class StockPicking(models.Model): .sudo() .search([("picking_type_id", "=", self.picking_type_id.id)]) ) - for operation in self.move_lines: + for operation in self.move_ids: trigger_lines = set() for model in [ "qc.trigger.product_category_line", diff --git a/quality_control_stock_oca/models/stock_production_lot.py b/quality_control_stock_oca/models/stock_production_lot.py index e1c83a9d3..654e6c5b4 100644 --- a/quality_control_stock_oca/models/stock_production_lot.py +++ b/quality_control_stock_oca/models/stock_production_lot.py @@ -6,7 +6,7 @@ from odoo import api, fields, models class StockProductionLot(models.Model): - _inherit = "stock.production.lot" + _inherit = "stock.lot" qc_inspections_ids = fields.One2many( comodel_name="qc.inspection", diff --git a/quality_control_stock_oca/static/description/index.html b/quality_control_stock_oca/static/description/index.html index 70d977666..6291209f8 100644 --- a/quality_control_stock_oca/static/description/index.html +++ b/quality_control_stock_oca/static/description/index.html @@ -367,9 +367,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:6a7081017d1705e47f1c601056c9db6f3dd3368a22519f03457e7f239cf92505 +!! source digest: sha256:7430252681826a0a0f9a869194458e38ac20900898f0f8ff40422f13702695ee !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runboat

This module defines triggers that creates inspections when stock moves are done.

It also adds some shortcuts on picking and lots to these inspections.

Table of contents

@@ -396,7 +396,7 @@ ul.auto-toc {

Bugs are tracked on GitHub 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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -432,7 +432,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/manufacture project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/quality_control_stock_oca/tests/test_quality_control_stock.py b/quality_control_stock_oca/tests/test_quality_control_stock.py index f9f7afa7d..4fa15aec2 100644 --- a/quality_control_stock_oca/tests/test_quality_control_stock.py +++ b/quality_control_stock_oca/tests/test_quality_control_stock.py @@ -2,7 +2,7 @@ # Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests.common import TransactionCase, new_test_user +from odoo.tests.common import TransactionCase class TestQualityControl(TransactionCase): @@ -19,6 +19,10 @@ class TestQualityControl(TransactionCase): self.test = self.env.ref("quality_control_oca.qc_test_1") self.picking_type = self.env.ref("stock.picking_type_out") self.location_dest = self.env.ref("stock.stock_location_customers") + self.group_stock_user = self.env.ref("stock.group_stock_user") + self.group_quality_control_user = self.env.ref( + "quality_control_oca.group_quality_control_user" + ) self.company = self.env.ref("base.main_company") self.sequence = self.env["ir.sequence"].create( {"code": "out", "name": "outgoing_sequence"} @@ -30,19 +34,18 @@ class TestQualityControl(TransactionCase): self.trigger = self.qc_trigger_model.search( [("picking_type_id", "=", self.picking_type.id)] ) - self.lot = self.env["stock.production.lot"].create( + self.lot = self.env["stock.lot"].create( { "name": "Lot for tests", "product_id": self.product.id, "company_id": self.company.id, } ) - self.user1_id = new_test_user( - self.env, - login="user_1", - groups="stock.group_stock_user,quality_control_oca.group_quality_control_user", - company_id=self.company.id, - ).id + self.user1_id = self._create_user( + "user_1", + [self.group_stock_user, self.group_quality_control_user], + self.company, + ) move_vals = { "name": self.product.name, "product_id": self.product.id, @@ -50,7 +53,6 @@ class TestQualityControl(TransactionCase): "product_uom_qty": 2.0, "location_id": self.picking_type.default_location_src_id.id, "location_dest_id": self.location_dest.id, - "quantity_done": 1.0, } self.picking1 = ( self.picking_model.with_user(self.user1_id) @@ -59,14 +61,14 @@ class TestQualityControl(TransactionCase): { "partner_id": self.partner1.id, "picking_type_id": self.picking_type.id, - "move_lines": [(0, 0, move_vals)], + "move_ids": [(0, 0, move_vals)], "location_dest_id": self.location_dest.id, } ) ) self.picking1.action_confirm() sequence = 10 - for line in self.picking1.move_lines.filtered( + for line in self.picking1.move_ids.filtered( lambda r: r.product_id == self.product ): line.write( @@ -77,7 +79,6 @@ class TestQualityControl(TransactionCase): 0, { "lot_id": self.lot.id, - "product_uom_qty": 1.0, "qty_done": 1.0, "product_uom_id": line.product_uom.id, "product_id": line.product_id.id, @@ -91,29 +92,45 @@ class TestQualityControl(TransactionCase): ) sequence += 10 + def _create_user(self, login, groups, company): + """Create a user.""" + group_ids = [group.id for group in groups] + user = self.users_model.with_context(no_reset_password=True).create( + { + "name": "Sale User", + "login": login, + "password": "test", + "email": "test@yourcompany.com", + "company_id": company.id, + "company_ids": [(4, company.id)], + "groups_id": [(6, 0, group_ids)], + } + ) + return user.id + def test_inspection_create_for_product(self): self.product.qc_triggers = [ (0, 0, {"trigger": self.trigger.id, "test": self.test.id}) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) inspection = self.picking1.qc_inspections_ids[:1] - self.assertEqual(inspection.qty, 2.0) + self.assertEqual(inspection.qty, self.picking1.move_ids.product_uom_qty) self.assertEqual( inspection.test, self.test, "Wrong test picked when creating inspection." ) # Try in this context if onchange with an stock.pack.operation works inspection.qty = 5 inspection.onchange_object_id() - self.assertEqual(inspection.qty, 2.0) + self.assertEqual(inspection.qty, self.picking1.move_ids.product_uom_qty) def test_inspection_create_for_template(self): self.product.product_tmpl_id.qc_triggers = [ (0, 0, {"trigger": self.trigger.id, "test": self.test.id}) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) @@ -127,7 +144,7 @@ class TestQualityControl(TransactionCase): self.product.categ_id.qc_triggers = [ (0, 0, {"trigger": self.trigger.id, "test": self.test.id}) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) @@ -149,7 +166,7 @@ class TestQualityControl(TransactionCase): }, ) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) @@ -171,7 +188,7 @@ class TestQualityControl(TransactionCase): }, ) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) @@ -193,7 +210,7 @@ class TestQualityControl(TransactionCase): }, ) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) @@ -215,7 +232,7 @@ class TestQualityControl(TransactionCase): }, ) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 0, "No inspection must be created" ) @@ -232,7 +249,7 @@ class TestQualityControl(TransactionCase): }, ) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 0, "No inspection must be created" ) @@ -249,7 +266,7 @@ class TestQualityControl(TransactionCase): }, ) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 0, "No inspection must be created" ) @@ -261,7 +278,7 @@ class TestQualityControl(TransactionCase): self.product.categ_id.qc_triggers = [ (0, 0, {"trigger": self.trigger.id, "test": self.test.id}) ] - self.picking1.button_validate() + self.picking1._action_done() self.assertEqual( self.picking1.created_inspections, 1, "Only one inspection must be created" ) @@ -307,7 +324,7 @@ class TestQualityControl(TransactionCase): def test_qc_inspection_picking(self): self.inspection1.write( { - "name": self.picking1.move_lines[:1]._name + "inspection", + "name": self.picking1.move_ids[:1]._name + "inspection", "object_id": "%s,%d" % (self.picking1._name, self.picking1.id), } ) @@ -316,23 +333,25 @@ class TestQualityControl(TransactionCase): def test_qc_inspection_stock_move(self): self.inspection1.write( { - "name": self.picking1.move_lines[:1]._name + "inspection", + "name": self.picking1.move_ids[:1]._name + "inspection", "object_id": "%s,%d" - % (self.picking1.move_lines[:1]._name, self.picking1.move_lines[:1].id), + % (self.picking1.move_ids[:1]._name, self.picking1.move_ids[:1].id), } ) self.inspection1.onchange_object_id() self.assertEqual(self.inspection1.picking_id, self.picking1) self.assertEqual(self.inspection1.lot_id, self.lot) self.assertEqual( - self.inspection1.product_id, self.picking1.move_lines[:1].product_id + self.inspection1.product_id, self.picking1.move_ids[:1].product_id + ) + self.assertEqual( + self.inspection1.qty, self.picking1.move_ids[:1].product_uom_qty ) - self.assertEqual(self.inspection1.qty, self.picking1.move_lines[:1].product_qty) def test_qc_inspection_lot(self): self.inspection1.write( { - "name": self.picking1.move_lines[:1]._name + "inspection", + "name": self.picking1.move_ids[:1]._name + "inspection", "object_id": "%s,%d" % (self.lot._name, self.lot.id), } ) diff --git a/quality_control_stock_oca/views/qc_trigger_view.xml b/quality_control_stock_oca/views/qc_trigger_view.xml new file mode 100644 index 000000000..338c64e42 --- /dev/null +++ b/quality_control_stock_oca/views/qc_trigger_view.xml @@ -0,0 +1,13 @@ + + + + qc.trigger.form + qc.trigger + + + + + + + + diff --git a/quality_control_stock_oca/views/stock_picking_view.xml b/quality_control_stock_oca/views/stock_picking_view.xml index 59c0b94a6..3b3c8caef 100644 --- a/quality_control_stock_oca/views/stock_picking_view.xml +++ b/quality_control_stock_oca/views/stock_picking_view.xml @@ -36,10 +36,6 @@ stock.picking.qc.view stock.picking -
@@ -67,6 +65,7 @@ type="action" name="%(action_qc_inspection_per_picking_passed)d" icon="fa-thumbs-o-up" + groups="quality_control_oca.group_quality_control_user" > @@ -75,8 +74,13 @@ type="action" name="%(action_qc_inspection_per_picking_failed)d" icon="fa-thumbs-o-down" + groups="quality_control_oca.group_quality_control_user" > - +
diff --git a/quality_control_stock_oca/views/stock_production_lot_view.xml b/quality_control_stock_oca/views/stock_production_lot_view.xml index 63b2eb167..afed0e533 100644 --- a/quality_control_stock_oca/views/stock_production_lot_view.xml +++ b/quality_control_stock_oca/views/stock_production_lot_view.xml @@ -33,13 +33,9 @@ >[('lot_id', '=', active_id), ('state', '=', 'failed')]
- stock.production.lot.qc.view - stock.production.lot + stock.lot.qc.view + stock.lot -
@@ -67,6 +65,7 @@ type="action" name="%(action_qc_inspection_per_lot_passed)d" icon="fa-thumbs-o-up" + groups="quality_control_oca.group_quality_control_user" > @@ -75,8 +74,13 @@ type="action" name="%(action_qc_inspection_per_lot_failed)d" icon="fa-thumbs-o-down" + groups="quality_control_oca.group_quality_control_user" > - +