diff --git a/repair_picking/README.rst b/repair_picking/README.rst index 5da12a80d..e6c9c92b5 100644 --- a/repair_picking/README.rst +++ b/repair_picking/README.rst @@ -13,9 +13,9 @@ Repair Picking .. |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-LGPL--3-blue.png - :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html - :alt: License: LGPL-3 +.. |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/14.0/repair_picking :alt: OCA/manufacture diff --git a/repair_picking/__manifest__.py b/repair_picking/__manifest__.py index e1d9ba86e..1f5d67309 100644 --- a/repair_picking/__manifest__.py +++ b/repair_picking/__manifest__.py @@ -3,18 +3,17 @@ { "name": "Repair Picking", - "version": "14.0.1.0.0", + "version": "14.0.1.0.1", "author": "ForgeFlow, Odoo Community Association (OCA)", "category": "Repair", "website": "https://github.com/OCA/manufacture", "summary": "Enhanced repair order management with pickings " "for adding and removing components", - "depends": ["repair", "stock_move_forced_lot", "repair_stock_move"], + "depends": ["stock_move_forced_lot", "repair_stock_move", "repair_stock"], "data": [ "views/stock_warehouse_views.xml", - "views/repair_order_view.xml", ], - "license": "LGPL-3", + "license": "AGPL-3", "installable": True, "auto_install": False, } diff --git a/repair_picking/models/repair.py b/repair_picking/models/repair.py index 69c84edbc..bc85c8759 100644 --- a/repair_picking/models/repair.py +++ b/repair_picking/models/repair.py @@ -23,36 +23,10 @@ class RepairOrder(models.Model): location_id = fields.Many2one( default=_get_default_location_id, ) - - picking_ids = fields.Many2many( - comodel_name="stock.picking", - compute="_compute_picking_ids", - copy=False, - string="Pickings associated to this repair order", - ) - picking_count = fields.Integer( - string="Transfers", copy=False, compute="_compute_picking_ids" - ) procurement_group_id = fields.Many2one( "procurement.group", "Procurement Group", copy=False ) - def action_view_pickings(self): - self.ensure_one() - action = self.env["ir.actions.actions"]._for_xml_id( - "stock.action_picking_tree_all" - ) - action["domain"] = [("id", "in", self.picking_ids.ids)] - return action - - def _compute_picking_ids(self): - for order in self: - moves = self.env["stock.move"].search( - [("repair_line_id", "in", order.operations.ids)] - ) - order.picking_ids = moves.mapped("picking_id") - order.picking_count = len(moves.mapped("picking_id")) - def action_repair_cancel(self): res = super().action_repair_cancel() for picking in self.picking_ids: diff --git a/repair_picking/static/description/index.html b/repair_picking/static/description/index.html index ceed62588..d11ac7556 100644 --- a/repair_picking/static/description/index.html +++ b/repair_picking/static/description/index.html @@ -368,7 +368,7 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:576ed4d5c0c1e57002a5f0fbd364f753297c27ebe3e35595ae64c9cd000b216d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-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 extends the repair management functionality in Odoo, providing additional options for handling the repair process in a more customizable and efficient way. It allows the configuration of repair steps based on specific business requirements diff --git a/repair_picking_after_done/__manifest__.py b/repair_picking_after_done/__manifest__.py index 47ee87e91..187a9e474 100644 --- a/repair_picking_after_done/__manifest__.py +++ b/repair_picking_after_done/__manifest__.py @@ -3,12 +3,12 @@ { "name": "Repair picking after done", - "version": "14.0.1.0.1", + "version": "14.0.1.0.2", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/manufacture", "summary": "Transfer repaired move to another location directly from repaire order", "category": "Repair", - "depends": ["repair_type"], + "depends": ["repair_type", "repair_stock"], "data": [ "security/ir.model.access.csv", "views/repair.xml", diff --git a/repair_picking_after_done/migration/14.0.1.0.2/pre-migration.py b/repair_picking_after_done/migration/14.0.1.0.2/pre-migration.py new file mode 100644 index 000000000..fc21d2634 --- /dev/null +++ b/repair_picking_after_done/migration/14.0.1.0.2/pre-migration.py @@ -0,0 +1,8 @@ +# Copyright 2024 ForgeFlow, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + + +def migrate(env, version): + repairs = env["repair.order"].search([]) + for repair in repairs: + repair.picking_ids.move_ids.write({"repair_id": repair.id}) diff --git a/repair_picking_after_done/models/repair.py b/repair_picking_after_done/models/repair.py index 27e054956..892d09bb4 100644 --- a/repair_picking_after_done/models/repair.py +++ b/repair_picking_after_done/models/repair.py @@ -1,13 +1,12 @@ # Copyright (C) 2022 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from odoo import _, fields, models +from odoo import fields, models class Repair(models.Model): _inherit = "repair.order" - picking_ids = fields.Many2many("stock.picking", string="Transfers") remaining_quantity = fields.Float( "Remaining quantity to be transferred", compute="_compute_remaining_quantity" ) @@ -38,17 +37,3 @@ class Repair(models.Model): }, "target": "new", } - - def action_open_transfers(self): - self.ensure_one() - domain = [("id", "in", self.picking_ids.ids)] - action = { - "name": _("Transfers"), - "view_type": "tree", - "view_mode": "list,form", - "res_model": "stock.picking", - "type": "ir.actions.act_window", - "context": self.env.context, - "domain": domain, - } - return action diff --git a/repair_picking_after_done/static/description/index.html b/repair_picking_after_done/static/description/index.html index 472e33034..ff399e1c3 100644 --- a/repair_picking_after_done/static/description/index.html +++ b/repair_picking_after_done/static/description/index.html @@ -1,4 +1,3 @@ - diff --git a/repair_picking_after_done/views/repair.xml b/repair_picking_after_done/views/repair.xml index 7b3fcf412..8ed2c13b5 100644 --- a/repair_picking_after_done/views/repair.xml +++ b/repair_picking_after_done/views/repair.xml @@ -6,6 +6,7 @@

+
- - - - - diff --git a/repair_picking_after_done/wizards/repair_move_transfer.py b/repair_picking_after_done/wizards/repair_move_transfer.py index 2a1cd7a93..6ac038a52 100644 --- a/repair_picking_after_done/wizards/repair_move_transfer.py +++ b/repair_picking_after_done/wizards/repair_move_transfer.py @@ -46,6 +46,7 @@ class MrpInventoryProcure(models.TransientModel): "picking_type_id": self._get_picking_type().id, "product_uom_qty": self.quantity, "product_uom": self.repair_order_id.move_id.product_uom.id, + "repair_id": self.repair_order_id.id, } def action_create_transfer(self): @@ -69,4 +70,4 @@ class MrpInventoryProcure(models.TransientModel): stock_move.move_line_ids[0]._assign_production_lot( self.repair_order_id.lot_id ) - self.repair_order_id.write({"picking_ids": [(4, picking.id)]}) + self.repair_order_id._compute_picking_ids() diff --git a/repair_stock/README.rst b/repair_stock/README.rst new file mode 100644 index 000000000..f35986067 --- /dev/null +++ b/repair_stock/README.rst @@ -0,0 +1,78 @@ +============ +Repair Stock +============ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:576ed4d5c0c1e57002a5f0fbd364f753297c27ebe3e35595ae64c9cd000b216d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.0/repair_stock + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-repair_stock + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module acts as a base for the stock related modules for repairs. +It adds some common features that may be overriding between them, +as the compute for the pickings or the smart button for the transfers. + +**Table of contents** + +.. contents:: + :local: + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* David Jimenez + +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. + +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/repair_stock/__init__.py b/repair_stock/__init__.py new file mode 100644 index 000000000..0ee8b5073 --- /dev/null +++ b/repair_stock/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import tests diff --git a/repair_stock/__manifest__.py b/repair_stock/__manifest__.py new file mode 100644 index 000000000..c029bc2f8 --- /dev/null +++ b/repair_stock/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Repair Stock", + "version": "14.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "category": "Repair", + "website": "https://github.com/OCA/manufacture", + "depends": ["repair_stock_move"], + "data": [ + "views/repair_order_view.xml", + ], + "license": "AGPL-3", +} diff --git a/repair_stock/models/__init__.py b/repair_stock/models/__init__.py new file mode 100644 index 000000000..316313ecf --- /dev/null +++ b/repair_stock/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import repair diff --git a/repair_stock/models/repair.py b/repair_stock/models/repair.py new file mode 100644 index 000000000..61811cf72 --- /dev/null +++ b/repair_stock/models/repair.py @@ -0,0 +1,38 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + picking_ids = fields.Many2many( + comodel_name="stock.picking", + compute="_compute_picking_ids", + copy=False, + string="Transfers", + ) + picking_count = fields.Integer( + string="Transfers", copy=False, compute="_compute_picking_ids" + ) + + def action_view_pickings(self): + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "stock.action_picking_tree_all" + ) + action["domain"] = [("id", "in", self.picking_ids.ids)] + return action + + def _compute_picking_ids(self): + for order in self: + moves = self.env["stock.move"].search( + [ + "|", + ("repair_id", "=", order.id), + ("repair_line_id", "in", order.operations.ids), + ] + ) + order.picking_ids = moves.mapped("picking_id") + order.picking_count = len(moves.mapped("picking_id")) diff --git a/repair_stock/readme/CONTRIBUTORS.rst b/repair_stock/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..11b57a1e5 --- /dev/null +++ b/repair_stock/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* David Jimenez diff --git a/repair_stock/readme/DESCRIPTION.rst b/repair_stock/readme/DESCRIPTION.rst new file mode 100644 index 000000000..0efcc233d --- /dev/null +++ b/repair_stock/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module acts as a base for the stock related modules for repairs. +It adds some common features that may be overriding between them, +as the compute for the pickings or the smart button for the transfers. diff --git a/repair_stock/static/description/icon.png b/repair_stock/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/repair_stock/static/description/icon.png differ diff --git a/repair_stock/static/description/index.html b/repair_stock/static/description/index.html new file mode 100644 index 000000000..6cbf9d01b --- /dev/null +++ b/repair_stock/static/description/index.html @@ -0,0 +1,422 @@ + + + + + +Repair Stock + + + +
+

Repair Stock

+ + +

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

+

This module acts as a base for the stock related modules for repairs. +It adds some common features that may be overriding between them, +as the compute for the pickings or the smart button for the transfers.

+

Table of contents

+ +
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/repair_stock/tests/__init__.py b/repair_stock/tests/__init__.py new file mode 100644 index 000000000..3f1b05c4a --- /dev/null +++ b/repair_stock/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import test_stock_repair_order diff --git a/repair_stock/tests/test_stock_repair_order.py b/repair_stock/tests/test_stock_repair_order.py new file mode 100644 index 000000000..7ac7b5fb5 --- /dev/null +++ b/repair_stock/tests/test_stock_repair_order.py @@ -0,0 +1,122 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestStockRepairOrder(common.SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.repair_model = cls.env["repair.order"] + cls.repair_line_model = cls.env["repair.line"] + cls.product_model = cls.env["product.product"] + cls.stock_location_model = cls.env["stock.location"] + cls.warehouse_model = cls.env["stock.warehouse"] + cls.company = cls.env.ref("base.main_company") + cls.warehouse = cls.warehouse_model.create( + { + "name": "Test Warehouse", + "code": "TW", + "company_id": cls.company.id, + } + ) + + cls.product1 = cls.product_model.create( + { + "name": "Product 1", + "type": "product", + "company_id": cls.company.id, + } + ) + cls.product2 = cls.product_model.create( + { + "name": "Product 2", + "type": "product", + "company_id": cls.company.id, + } + ) + cls.repair_location = cls.stock_location_model.create( + { + "name": "Repair Location", + "usage": "internal", + "location_id": cls.warehouse.view_location_id.id, + "company_id": cls.company.id, + } + ) + cls.production_location = cls.stock_location_model.create( + { + "name": "Production Location", + "usage": "production", + "company_id": cls.company.id, + } + ) + cls.env["stock.quant"].create( + { + "product_id": cls.product1.id, + "location_id": cls.repair_location.id, + "quantity": 10, + } + ) + cls.env["stock.quant"].create( + { + "product_id": cls.product2.id, + "location_id": cls.warehouse.lot_stock_id.id, + "quantity": 10, + } + ) + + def test_compute_pickings(self): + repair_order = self.repair_model.create( + { + "product_id": self.product1.id, + "product_uom": self.product1.uom_id.id, + "location_id": self.repair_location.id, + "company_id": self.company.id, + } + ) + self.repair_line_model.create( + { + "name": "Repair Line 2", + "repair_id": repair_order.id, + "product_id": self.product2.id, + "type": "add", + "product_uom_qty": 1, + "product_uom": self.product2.uom_id.id, + "price_unit": 1, + "location_id": self.repair_location.id, + "location_dest_id": self.production_location.id, + } + ) + repair_order.action_repair_confirm() + repair_order._compute_picking_ids() + self.assertEqual(len(repair_order.picking_ids), 0) + picking = self.env["stock.picking"].create( + { + "partner_id": False, + "user_id": False, + "picking_type_id": self.warehouse.int_type_id.id, + "move_type": "direct", + "location_id": self.repair_location.id, + "location_dest_id": self.production_location.id, + } + ) + self.env["stock.move"].create( + { + "name": repair_order.product_id.name, + "product_id": repair_order.product_id.id, + "location_id": repair_order.location_id.id, + "location_dest_id": self.production_location.id, + "picking_id": picking.id, + "state": "draft", + "company_id": picking.company_id.id, + "picking_type_id": self.warehouse.int_type_id.id, + "product_uom_qty": 1, + "product_uom": repair_order.move_id.product_uom.id, + "repair_id": repair_order.id, + } + ) + repair_order._compute_picking_ids() + self.assertTrue(repair_order.picking_ids) + self.assertEqual(len(repair_order.picking_ids), 1) diff --git a/repair_picking/views/repair_order_view.xml b/repair_stock/views/repair_order_view.xml similarity index 81% rename from repair_picking/views/repair_order_view.xml rename to repair_stock/views/repair_order_view.xml index 7c25297b9..9667f627f 100644 --- a/repair_picking/views/repair_order_view.xml +++ b/repair_stock/views/repair_order_view.xml @@ -1,9 +1,13 @@ + repair.order.form - repair_stock_move - custom repair.order - +