diff --git a/repair_stock/README.rst b/repair_stock/README.rst new file mode 100644 index 00000000..4e9311da --- /dev/null +++ b/repair_stock/README.rst @@ -0,0 +1,86 @@ +============ +Repair Stock +============ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e5f38d7da6b61c566a431044972a232c89b78faf6eed0fbae77dcf335dd8ed1c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/17.0/repair_stock + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-17-0/repair-17-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/repair&target_branch=17.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. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 +- `APSL-Nagarro `__: + + - Patryk Pyczko + +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/repair `_ 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 00000000..0650744f --- /dev/null +++ b/repair_stock/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/repair_stock/__manifest__.py b/repair_stock/__manifest__.py new file mode 100644 index 00000000..df2bc531 --- /dev/null +++ b/repair_stock/__manifest__.py @@ -0,0 +1,16 @@ +# 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": "17.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "category": "Repair", + "website": "https://github.com/OCA/repair", + "depends": ["repair"], + "data": [ + "views/repair_order_view.xml", + ], + "license": "AGPL-3", + "development_status": "Alpha", +} diff --git a/repair_stock/i18n/it.po b/repair_stock/i18n/it.po new file mode 100644 index 00000000..6ced9329 --- /dev/null +++ b/repair_stock/i18n/it.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-08-31 11:06+0000\n" +"Last-Translator: mymage \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 5.6.2\n" + +#. module: repair_stock +#: model:ir.model,name:repair_stock.model_repair_order +msgid "Repair Order" +msgstr "Ordine di riparazione" + +#. module: repair_stock +#: model:ir.model.fields,field_description:repair_stock.field_repair_order__picking_count +#: model:ir.model.fields,field_description:repair_stock.field_repair_order__picking_ids +#: model_terms:ir.ui.view,arch_db:repair_stock.view_repair_order_form_repair_stock_move_inherited +msgid "Transfers" +msgstr "Trasferimenti" + +#. module: repair_stock +#: model_terms:ir.ui.view,arch_db:repair_stock.view_repair_order_form_repair_stock_move_inherited +msgid "Transfers associated with this repair order" +msgstr "Trasferimenti associati a questo ordine di riparazione" diff --git a/repair_stock/i18n/repair_stock.pot b/repair_stock/i18n/repair_stock.pot new file mode 100644 index 00000000..b8558be6 --- /dev/null +++ b/repair_stock/i18n/repair_stock.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: repair_stock +#: model:ir.model,name:repair_stock.model_repair_order +msgid "Repair Order" +msgstr "" + +#. module: repair_stock +#: model:ir.model.fields,field_description:repair_stock.field_repair_order__picking_count +#: model:ir.model.fields,field_description:repair_stock.field_repair_order__picking_ids +#: model_terms:ir.ui.view,arch_db:repair_stock.view_repair_order_form_repair_stock_move_inherited +msgid "Transfers" +msgstr "" + +#. module: repair_stock +#: model_terms:ir.ui.view,arch_db:repair_stock.view_repair_order_form_repair_stock_move_inherited +msgid "Transfers associated with this repair order" +msgstr "" diff --git a/repair_stock/models/__init__.py b/repair_stock/models/__init__.py new file mode 100644 index 00000000..316313ec --- /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 00000000..1f85f7a4 --- /dev/null +++ b/repair_stock/models/repair.py @@ -0,0 +1,36 @@ +# 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), + ] + ) + order.picking_ids = moves.mapped("picking_id") + order.picking_count = len(moves.mapped("picking_id")) diff --git a/repair_stock/pyproject.toml b/repair_stock/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_stock/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_stock/readme/CONTRIBUTORS.md b/repair_stock/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..d8b2f958 --- /dev/null +++ b/repair_stock/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- David Jimenez \<\> +- [APSL-Nagarro](https://www.apsl.tech): + - Patryk Pyczko \<\> \ No newline at end of file diff --git a/repair_stock/readme/DESCRIPTION.md b/repair_stock/readme/DESCRIPTION.md new file mode 100644 index 00000000..d75e2d6e --- /dev/null +++ b/repair_stock/readme/DESCRIPTION.md @@ -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 00000000..3a0328b5 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 00000000..d30b637f --- /dev/null +++ b/repair_stock/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +Repair Stock + + + +
+

Repair Stock

+ + +

Alpha License: AGPL-3 OCA/repair 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.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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/repair 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 00000000..3f1b05c4 --- /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 00000000..53a19f72 --- /dev/null +++ b/repair_stock/tests/test_stock_repair_order.py @@ -0,0 +1,134 @@ +# 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.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.repair_model = cls.env["repair.order"] + 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 _create_repair_order(self, product): + return self.repair_model.create( + { + "product_id": product.id, + "product_uom": product.uom_id.id, + "location_id": self.repair_location.id, + "company_id": self.company.id, + } + ) + + def _create_picking_and_move(self, repair_order): + 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, + "company_id": self.company.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.product_id.uom_id.id, + "repair_id": repair_order.id, + } + ) + return picking + + def test_compute_pickings(self): + repair_order = self._create_repair_order(self.product1) + repair_order._action_repair_confirm() + repair_order._compute_picking_ids() + self.assertEqual(len(repair_order.picking_ids), 0) + + self._create_picking_and_move(repair_order) + repair_order._compute_picking_ids() + self.assertTrue(repair_order.picking_ids) + self.assertEqual(len(repair_order.picking_ids), 1) + + def test_action_view_pickings(self): + repair_order = self._create_repair_order(self.product1) + repair_order._action_repair_confirm() + + picking = self._create_picking_and_move(repair_order) + repair_order._compute_picking_ids() + + action = repair_order.action_view_pickings() + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["res_model"], "stock.picking") + self.assertIn("domain", action) + self.assertEqual(action["domain"], [("id", "in", repair_order.picking_ids.ids)]) + self.assertEqual(len(repair_order.picking_ids), 1) + self.assertEqual(repair_order.picking_ids[0], picking) diff --git a/repair_stock/views/repair_order_view.xml b/repair_stock/views/repair_order_view.xml new file mode 100644 index 00000000..53d66e3d --- /dev/null +++ b/repair_stock/views/repair_order_view.xml @@ -0,0 +1,26 @@ + + + + + repair.order.form - repair_stock_move - custom + repair.order + + + + + + + +