diff --git a/repair_type_product_destination/README.rst b/repair_type_product_destination/README.rst new file mode 100644 index 00000000..806ee6d1 --- /dev/null +++ b/repair_type_product_destination/README.rst @@ -0,0 +1,114 @@ +================================= +Repair Type - Product Destination +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:841f2e7afbe4c6e48966faef1044973142b77bb7a11d8be86488044a4fd7cad5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/17.0/repair_type_product_destination + :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_type_product_destination + :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 is a technical module, and it does not provide any new +functionality on its own. Due to the way transfers of repaired products +work in Odoo, the following fields will not have any effect without +additional code modifications. + +This module introduces a **Product Destination Location field** in the +repair order. The default value for this field is computed from the +**Default Product Destination Location field of the associated Operation +Type**. + +This module essentially serves as a template, providing the groundwork +for further customization. To make use of the functionality it +introduces, extend this module to implement additional features in the +repair transfer workflow. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +The following fields are available in the Repair module: + +1. **Product Destination Location** + +- Repairs > Orders > Select or create an order > Miscellaneous > + Product Destination Location + +2. **Default Product Destination Location** + +- Repairs > Orders > Select or create an order > Miscellaneous > + Operation Type > Default Product Destination Location + +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 +------- + +* APSL-Nagarro + +Contributors +------------ + +- `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. + +.. |maintainer-ppyczko| image:: https://github.com/ppyczko.png?size=40px + :target: https://github.com/ppyczko + :alt: ppyczko + +Current `maintainer `__: + +|maintainer-ppyczko| + +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_type_product_destination/__init__.py b/repair_type_product_destination/__init__.py new file mode 100644 index 00000000..31660d6a --- /dev/null +++ b/repair_type_product_destination/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/repair_type_product_destination/__manifest__.py b/repair_type_product_destination/__manifest__.py new file mode 100644 index 00000000..fbacc82f --- /dev/null +++ b/repair_type_product_destination/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Repair Type - Product Destination", + "version": "17.0.1.0.0", + "category": "Repair", + "website": "https://github.com/OCA/repair", + "author": "APSL-Nagarro, Odoo Community Association (OCA)", + "maintainers": ["ppyczko"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["repair"], + "data": ["views/repair_views.xml", "views/stock_picking_type_views.xml"], +} diff --git a/repair_type_product_destination/i18n/ca.po b/repair_type_product_destination/i18n/ca.po new file mode 100644 index 00000000..2b1e93dc --- /dev/null +++ b/repair_type_product_destination/i18n/ca.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type_product_destination +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 13:39+0000\n" +"PO-Revision-Date: 2024-11-28 13:39+0000\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_type_product_destination +#: model:ir.model.fields,field_description:repair_type_product_destination.field_stock_picking_type__default_product_location_dest_id +msgid "Default Product Destination Location" +msgstr "Ubicació de destinació per defecte del producte" + +#. module: repair_type_product_destination +#: model:ir.model,name:repair_type_product_destination.model_stock_picking_type +msgid "Picking Type" +msgstr "Tipus de picking" + +#. module: repair_type_product_destination +#: model:ir.model.fields,field_description:repair_type_product_destination.field_repair_order__product_location_dest_id +msgid "Product Destination Location" +msgstr "Ubicació de destinació del producte" + +#. module: repair_type_product_destination +#: model:ir.model,name:repair_type_product_destination.model_repair_order +msgid "Repair Order" +msgstr "Ordre de reparació" + +#. module: repair_type_product_destination +#: model:ir.model.fields,help:repair_type_product_destination.field_stock_picking_type__default_product_location_dest_id +msgid "" +"This is the default product destination location where the repaired product " +"will be stored.." +msgstr "Aquesta és la ubicació per defecte de destinació del producte on " +"s'emmagatzemarà el producte reparat." + +#. module: repair_type_product_destination +#: model:ir.model.fields,help:repair_type_product_destination.field_repair_order__product_location_dest_id +msgid "This is the location where the repaired product will be stored." +msgstr "Aquesta és la ubicació on s'emmagatzemarà el producte reparat." \ No newline at end of file diff --git a/repair_type_product_destination/i18n/es.po b/repair_type_product_destination/i18n/es.po new file mode 100644 index 00000000..46ed532d --- /dev/null +++ b/repair_type_product_destination/i18n/es.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type_product_destination +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 13:39+0000\n" +"PO-Revision-Date: 2024-11-28 13:39+0000\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_type_product_destination +#: model:ir.model.fields,field_description:repair_type_product_destination.field_stock_picking_type__default_product_location_dest_id +msgid "Default Product Destination Location" +msgstr "Ubicación de destino por defecto del producto" + +#. module: repair_type_product_destination +#: model:ir.model,name:repair_type_product_destination.model_stock_picking_type +msgid "Picking Type" +msgstr "Tipo de picking" + +#. module: repair_type_product_destination +#: model:ir.model.fields,field_description:repair_type_product_destination.field_repair_order__product_location_dest_id +msgid "Product Destination Location" +msgstr "Ubicación de destino del producto" + +#. module: repair_type_product_destination +#: model:ir.model,name:repair_type_product_destination.model_repair_order +msgid "Repair Order" +msgstr "Orden de reparación" + +#. module: repair_type_product_destination +#: model:ir.model.fields,help:repair_type_product_destination.field_stock_picking_type__default_product_location_dest_id +msgid "" +"This is the default product destination location where the repaired product " +"will be stored.." +msgstr "Esta es la ubicación predeterminada de destino del producto donde se " +"almacenará el producto reparado." + +#. module: repair_type_product_destination +#: model:ir.model.fields,help:repair_type_product_destination.field_repair_order__product_location_dest_id +msgid "This is the location where the repaired product will be stored." +msgstr "Esta es la ubicación donde se almacenará el producto reparado." \ No newline at end of file diff --git a/repair_type_product_destination/i18n/repair_type_product_destination.pot b/repair_type_product_destination/i18n/repair_type_product_destination.pot new file mode 100644 index 00000000..1190fa7d --- /dev/null +++ b/repair_type_product_destination/i18n/repair_type_product_destination.pot @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type_product_destination +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-28 13:39+0000\n" +"PO-Revision-Date: 2024-11-28 13:39+0000\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_type_product_destination +#: model:ir.model.fields,field_description:repair_type_product_destination.field_stock_picking_type__default_product_location_dest_id +msgid "Default Product Destination Location" +msgstr "" + +#. module: repair_type_product_destination +#: model:ir.model,name:repair_type_product_destination.model_stock_picking_type +msgid "Picking Type" +msgstr "" + +#. module: repair_type_product_destination +#: model:ir.model.fields,field_description:repair_type_product_destination.field_repair_order__product_location_dest_id +msgid "Product Destination Location" +msgstr "" + +#. module: repair_type_product_destination +#: model:ir.model,name:repair_type_product_destination.model_repair_order +msgid "Repair Order" +msgstr "" + +#. module: repair_type_product_destination +#: model:ir.model.fields,help:repair_type_product_destination.field_stock_picking_type__default_product_location_dest_id +msgid "" +"This is the default product destination location where the repaired product " +"will be stored.." +msgstr "" + +#. module: repair_type_product_destination +#: model:ir.model.fields,help:repair_type_product_destination.field_repair_order__product_location_dest_id +msgid "This is the location where the repaired product will be stored." +msgstr "" diff --git a/repair_type_product_destination/models/__init__.py b/repair_type_product_destination/models/__init__.py new file mode 100644 index 00000000..945de8bc --- /dev/null +++ b/repair_type_product_destination/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import repair +from . import stock_picking_type diff --git a/repair_type_product_destination/models/repair.py b/repair_type_product_destination/models/repair.py new file mode 100644 index 00000000..ad4599c3 --- /dev/null +++ b/repair_type_product_destination/models/repair.py @@ -0,0 +1,27 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + product_location_dest_id = fields.Many2one( + "stock.location", + "Product Destination Location", + compute="_compute_product_location_dest_id", + store=True, + required=True, + precompute=True, + index=True, + check_company=True, + help="This is the location where the repaired product will be stored.", + ) + + @api.depends("picking_type_id") + def _compute_product_location_dest_id(self): + for repair in self: + repair.product_location_dest_id = ( + repair.picking_type_id.default_product_location_dest_id + ) diff --git a/repair_type_product_destination/models/stock_picking_type.py b/repair_type_product_destination/models/stock_picking_type.py new file mode 100644 index 00000000..d4165d69 --- /dev/null +++ b/repair_type_product_destination/models/stock_picking_type.py @@ -0,0 +1,26 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class PickingType(models.Model): + _inherit = "stock.picking.type" + + default_product_location_dest_id = fields.Many2one( + "stock.location", + "Default Product Destination Location", + compute="_compute_default_product_location_dest_id", + check_company=True, + store=True, + precompute=True, + help="This is the default product destination location where " + "the repaired product will be stored..", + ) + + @api.depends("code") + def _compute_default_product_location_dest_id(self): + for picking_type in self: + stock_location = picking_type.warehouse_id.lot_stock_id + if picking_type.code == "repair_operation": + picking_type.default_product_location_dest_id = stock_location.id diff --git a/repair_type_product_destination/pyproject.toml b/repair_type_product_destination/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_type_product_destination/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_type_product_destination/readme/CONTRIBUTORS.md b/repair_type_product_destination/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..484bb742 --- /dev/null +++ b/repair_type_product_destination/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [APSL-Nagarro](https://www.apsl.tech): + - Patryk Pyczko \<\> \ No newline at end of file diff --git a/repair_type_product_destination/readme/DESCRIPTION.md b/repair_type_product_destination/readme/DESCRIPTION.md new file mode 100644 index 00000000..d835e0cc --- /dev/null +++ b/repair_type_product_destination/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +This is a technical module, and it does not provide any new functionality on its own. Due to the way transfers of repaired products work in Odoo, the following fields will not have any effect without additional code modifications. + +This module introduces a **Product Destination Location field** in the repair order. The default value for this field is computed from the **Default Product Destination Location field of the associated Operation Type**. + +This module essentially serves as a template, providing the groundwork for further customization. To make use of the functionality it introduces, extend this module to implement additional features in the repair transfer workflow. \ No newline at end of file diff --git a/repair_type_product_destination/readme/USAGE.md b/repair_type_product_destination/readme/USAGE.md new file mode 100644 index 00000000..7e99d77d --- /dev/null +++ b/repair_type_product_destination/readme/USAGE.md @@ -0,0 +1,7 @@ +The following fields are available in the Repair module: + +1. **Product Destination Location** +- Repairs > Orders > Select or create an order > Miscellaneous > Product Destination Location + +2. **Default Product Destination Location** +- Repairs > Orders > Select or create an order > Miscellaneous > Operation Type > Default Product Destination Location \ No newline at end of file diff --git a/repair_type_product_destination/static/description/icon.png b/repair_type_product_destination/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_type_product_destination/static/description/icon.png differ diff --git a/repair_type_product_destination/static/description/index.html b/repair_type_product_destination/static/description/index.html new file mode 100644 index 00000000..365b6145 --- /dev/null +++ b/repair_type_product_destination/static/description/index.html @@ -0,0 +1,458 @@ + + + + + +Repair Type - Product Destination + + + +
+

Repair Type - Product Destination

+ + +

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

+

This is a technical module, and it does not provide any new +functionality on its own. Due to the way transfers of repaired products +work in Odoo, the following fields will not have any effect without +additional code modifications.

+

This module introduces a Product Destination Location field in the +repair order. The default value for this field is computed from the +Default Product Destination Location field of the associated Operation +Type.

+

This module essentially serves as a template, providing the groundwork +for further customization. To make use of the functionality it +introduces, extend this module to implement additional features in the +repair transfer workflow.

+

Table of contents

+ +
+

Usage

+

The following fields are available in the Repair module:

+
    +
  1. Product Destination Location
  2. +
+
    +
  • Repairs > Orders > Select or create an order > Miscellaneous > +Product Destination Location
  • +
+
    +
  1. Default Product Destination Location
  2. +
+
    +
  • Repairs > Orders > Select or create an order > Miscellaneous > +Operation Type > Default Product Destination Location
  • +
+
+
+

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

+
    +
  • APSL-Nagarro
  • +
+
+
+

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.

+

Current maintainer:

+

ppyczko

+

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_type_product_destination/tests/__init__.py b/repair_type_product_destination/tests/__init__.py new file mode 100644 index 00000000..48e033be --- /dev/null +++ b/repair_type_product_destination/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_repair_type_product_destination diff --git a/repair_type_product_destination/tests/test_repair_type_product_destination.py b/repair_type_product_destination/tests/test_repair_type_product_destination.py new file mode 100644 index 00000000..a0f189fa --- /dev/null +++ b/repair_type_product_destination/tests/test_repair_type_product_destination.py @@ -0,0 +1,78 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestRepairTypeProductDestination(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.stock_location = cls.env["stock.location"].create( + { + "name": "Stock Location", + "usage": "internal", + } + ) + + cls.product_destination_location = cls.env["stock.location"].create( + { + "name": "Product Destination Location", + "usage": "internal", + } + ) + + cls.warehouse = cls.env["stock.warehouse"].create( + { + "name": "Test Warehouse", + "code": "TW", + "lot_stock_id": cls.stock_location.id, + } + ) + + cls.picking_type = cls.env["stock.picking.type"].create( + { + "name": "Repair Operation Type", + "code": "repair_operation", + "warehouse_id": cls.warehouse.id, + "default_location_src_id": cls.stock_location.id, + "default_product_location_dest_id": cls.product_destination_location.id, + "sequence_code": "RO", + } + ) + + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "type": "product", + } + ) + + cls.repair_order = cls.env["repair.order"].create( + { + "name": "Test Repair Order", + "picking_type_id": cls.picking_type.id, + "product_id": cls.product.id, + } + ) + + def test_product_location_dest_id_computation(self): + """Test that product_location_dest_id is correctly computed.""" + self.repair_order._compute_product_location_dest_id() + self.assertEqual( + self.repair_order.product_location_dest_id, + self.picking_type.default_product_location_dest_id, + "The product_location_dest_id should be set to the default location.", + ) + + def test_default_product_location_dest_id_computation(self): + """Test the computation of default_product_location_dest_id in picking type.""" + self.picking_type._compute_default_product_location_dest_id() + + self.assertEqual( + self.picking_type.default_product_location_dest_id, + self.picking_type.warehouse_id.lot_stock_id, + "The default_product_location_dest_id should be set to the " + "stock location when the code is 'repair_operation'.", + ) diff --git a/repair_type_product_destination/views/repair_views.xml b/repair_type_product_destination/views/repair_views.xml new file mode 100644 index 00000000..4f590ae5 --- /dev/null +++ b/repair_type_product_destination/views/repair_views.xml @@ -0,0 +1,37 @@ + + + + repair.type.repair.order.tree.inherit + repair.order + + + + + + + + + + repair.type.repair.order.form.inherit + repair.order + + + + + + + + diff --git a/repair_type_product_destination/views/stock_picking_type_views.xml b/repair_type_product_destination/views/stock_picking_type_views.xml new file mode 100644 index 00000000..6ad16187 --- /dev/null +++ b/repair_type_product_destination/views/stock_picking_type_views.xml @@ -0,0 +1,21 @@ + + + + stock.picking.type.inherit.repair.type + stock.picking.type + + + + + + + +