diff --git a/repair_stock_dest/README.rst b/repair_stock_dest/README.rst new file mode 100644 index 00000000..17648f9b --- /dev/null +++ b/repair_stock_dest/README.rst @@ -0,0 +1,102 @@ +======================== +Repair Stock Destination +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9587e8affbb8d43fccc9913b182c9315239eae5744525598bbc4617740afa122 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_stock_dest + :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_dest + :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 adds the destination location of the added parts to a repair +order. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +Create a repair order: + +1. Go to Repairs > Orders. +2. Create a new repair order. +3. Before confirming the repair, in the Miscellaneous tab, you can view + and change the Added Parts Destination Location. + +To be able to view the location related fields, make sure your user has +been added to the Technical / Manage Multiple Stock Locations group. + +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 +------- + +* Patryk Pyczko + +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_stock_dest/__init__.py b/repair_stock_dest/__init__.py new file mode 100644 index 00000000..a466ab60 --- /dev/null +++ b/repair_stock_dest/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models \ No newline at end of file diff --git a/repair_stock_dest/__manifest__.py b/repair_stock_dest/__manifest__.py new file mode 100644 index 00000000..921fda01 --- /dev/null +++ b/repair_stock_dest/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 Patryk Pyczko (APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Repair Stock Destination", + "summary": "Add destination field to a repair order", + "version": "17.0.1.0.0", + "category": "Repair", + "website": "https://github.com/OCA/repair", + "author": "Patryk Pyczko, Odoo Community Association (OCA)", + "maintainers": ["ppyczko"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["repair"], + "data": ["views/repair_views.xml"], +} diff --git a/repair_stock_dest/i18n/ca_ES.po b/repair_stock_dest/i18n/ca_ES.po new file mode 100644 index 00000000..8fe1eda3 --- /dev/null +++ b/repair_stock_dest/i18n/ca_ES.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_stock_dest +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-13 10:51+0000\n" +"PO-Revision-Date: 2024-09-13 10:51+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_stock_dest +#: model:ir.model.fields,field_description:repair_stock_dest.field_repair_order__location_dest_id +msgid "Added Parts Destination Location" +msgstr "Ubicació de destinació de les peces agregades" + +#. module: repair_stock_dest +#: model:ir.model,name:repair_stock_dest.model_repair_order +msgid "Repair Order" +msgstr "Ordre de reparació" + +#. module: repair_stock_dest +#: model:ir.model.fields,help:repair_stock_dest.field_repair_order__location_dest_id +msgid "This is the location where the repaired product is located." +msgstr "Aquesta és la ubicació on es troba el producte reparat." diff --git a/repair_stock_dest/i18n/es.po b/repair_stock_dest/i18n/es.po new file mode 100644 index 00000000..9717ca74 --- /dev/null +++ b/repair_stock_dest/i18n/es.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_stock_dest +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-13 10:48+0000\n" +"PO-Revision-Date: 2024-09-13 10:48+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_stock_dest +#: model:ir.model.fields,field_description:repair_stock_dest.field_repair_order__location_dest_id +msgid "Added Parts Destination Location" +msgstr "Ubicación de destino de las piezas agregadas" + +#. module: repair_stock_dest +#: model:ir.model,name:repair_stock_dest.model_repair_order +msgid "Repair Order" +msgstr "Orden de reparación" + +#. module: repair_stock_dest +#: model:ir.model.fields,help:repair_stock_dest.field_repair_order__location_dest_id +msgid "This is the location where the repaired product is located." +msgstr "Esta es la ubicación donde se encuentra el producto reparado." diff --git a/repair_stock_dest/models/__init__.py b/repair_stock_dest/models/__init__.py new file mode 100644 index 00000000..d2498a5e --- /dev/null +++ b/repair_stock_dest/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import repair diff --git a/repair_stock_dest/models/repair.py b/repair_stock_dest/models/repair.py new file mode 100644 index 00000000..38fb9eed --- /dev/null +++ b/repair_stock_dest/models/repair.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 RepairOrder(models.Model): + _inherit = "repair.order" + + location_dest_id = fields.Many2one( + "stock.location", + "Added Parts Destination Location", + compute="_compute_location_dest_id", + store=True, + readonly=False, + required=True, + precompute=True, + index=True, + check_company=True, + help="This is the location where the repaired product is located.", + ) + + @api.depends("picking_type_id") + def _compute_location_dest_id(self): + for repair in self: + repair.location_dest_id = repair.picking_type_id.default_location_dest_id diff --git a/repair_stock_dest/pyproject.toml b/repair_stock_dest/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_stock_dest/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_stock_dest/readme/CONTRIBUTORS.md b/repair_stock_dest/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..f413e101 --- /dev/null +++ b/repair_stock_dest/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [APSL-Nagarro](https://apsl.tech): + + > - Patryk Pyczko \<\> diff --git a/repair_stock_dest/readme/DESCRIPTION.md b/repair_stock_dest/readme/DESCRIPTION.md new file mode 100644 index 00000000..62c77bbc --- /dev/null +++ b/repair_stock_dest/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds the destination location of the added parts to a repair order. \ No newline at end of file diff --git a/repair_stock_dest/readme/USAGE.md b/repair_stock_dest/readme/USAGE.md new file mode 100644 index 00000000..89cea605 --- /dev/null +++ b/repair_stock_dest/readme/USAGE.md @@ -0,0 +1,9 @@ +To use this module, you need to: + +Create a repair order: + +1. Go to Repairs > Orders. +2. Create a new repair order. +3. Before confirming the repair, in the Miscellaneous tab, you can view and change the Added Parts Destination Location. + +To be able to view the location related fields, make sure your user has been added to the Technical / Manage Multiple Stock Locations group. \ No newline at end of file diff --git a/repair_stock_dest/static/description/icon.png b/repair_stock_dest/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_stock_dest/static/description/icon.png differ diff --git a/repair_stock_dest/static/description/index.html b/repair_stock_dest/static/description/index.html new file mode 100644 index 00000000..54356640 --- /dev/null +++ b/repair_stock_dest/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +Repair Stock Destination + + + +
+

Repair Stock Destination

+ + +

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

+

This module adds the destination location of the added parts to a repair +order.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+

Create a repair order:

+
    +
  1. Go to Repairs > Orders.
  2. +
  3. Create a new repair order.
  4. +
  5. Before confirming the repair, in the Miscellaneous tab, you can view +and change the Added Parts Destination Location.
  6. +
+

To be able to view the location related fields, make sure your user has +been added to the Technical / Manage Multiple Stock Locations group.

+
+
+

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

+
    +
  • Patryk Pyczko
  • +
+
+
+

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_stock_dest/tests/__init__.py b/repair_stock_dest/tests/__init__.py new file mode 100644 index 00000000..fd703344 --- /dev/null +++ b/repair_stock_dest/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_repair_order_location_dest diff --git a/repair_stock_dest/tests/test_repair_order_location_dest.py b/repair_stock_dest/tests/test_repair_order_location_dest.py new file mode 100644 index 00000000..c2c57e29 --- /dev/null +++ b/repair_stock_dest/tests/test_repair_order_location_dest.py @@ -0,0 +1,74 @@ +# 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 TestRepairOrderLocationDest(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.stock_location = cls.env["stock.location"].create( + { + "name": "Stock Location", + "usage": "internal", + } + ) + + cls.customer_location = cls.env["stock.location"].create( + { + "name": "Customer Location", + "usage": "customer", + } + ) + + cls.remove_location = cls.env["stock.location"].create( + { + "name": "Scrapped Location", + "usage": "inventory", + } + ) + + cls.picking_type = cls.env["stock.picking.type"].create( + { + "name": "Repair Operation Type", + "code": "repair_operation", + "default_location_src_id": cls.stock_location.id, + "default_location_dest_id": cls.customer_location.id, + "default_remove_location_dest_id": cls.remove_location.id, + "sequence_code": "RO", + } + ) + + cls.repair_order = cls.env["repair.order"].create( + { + "name": "Test Repair Order", + "picking_type_id": cls.picking_type.id, + } + ) + + def test_location_dest_id_computation(self): + """Test that location_dest_id is correctly computed""" + expected_location_dest_id = self.picking_type.default_location_dest_id + self.assertEqual( + self.repair_order.location_dest_id, + expected_location_dest_id, + "The computed location_dest_id should match the picking_type's default_location_dest_id.", + ) + + def test_location_dest_id_modification(self): + """Test that location_dest_id can be manually modified""" + custom_location = self.env["stock.location"].create( + { + "name": "Custom Location", + "usage": "internal", + } + ) + + self.repair_order.location_dest_id = custom_location.id + self.assertEqual( + self.repair_order.location_dest_id, + custom_location, + "The location_dest_id should be modifiable by the user.", + ) diff --git a/repair_stock_dest/views/repair_views.xml b/repair_stock_dest/views/repair_views.xml new file mode 100644 index 00000000..58fb3ad4 --- /dev/null +++ b/repair_stock_dest/views/repair_views.xml @@ -0,0 +1,34 @@ + + + + + + repair.order.tree.inherit + repair.order + + + + + + + + + + repair.form.form.inherit + repair.order + + + + + + + + +