diff --git a/repair_type/README.rst b/repair_type/README.rst new file mode 100644 index 00000000..c4e378ad --- /dev/null +++ b/repair_type/README.rst @@ -0,0 +1,106 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=========== +Repair Type +=========== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:31bbf1efb67b14ab0a9a33dd9d3d662c0898d03f1e518cc82c2ca806f804bdb9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/repair_type + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-19-0/repair-19-0-repair_type + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds support for source locations when adding, removing, or +recycling components. If you specify any of these types in a Repair +Order, Odoo will automatically apply the corresponding locations from +the related stock picking type to the stock moves. + +.. 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: + +Usage +===== + +- Set the stock picking type for repairs and define source locations for + adding, removing and recycling components. +- When you select this stock picking type in a Repair Order, Odoo will + automatically assign the specified source locations to the stock moves + for the respective components. + +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 +------------ + +- `ForgeFlow `__: + + - Bernat Puig + +- `APSL-Nagarro `__: + + - Antoni Marroig + - Miquel Alzanillas > + +- ``Heliconia Solutions Pvt. Ltd. ``\ \_ + +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_type/__init__.py b/repair_type/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/repair_type/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/repair_type/__manifest__.py b/repair_type/__manifest__.py new file mode 100644 index 00000000..fa1096af --- /dev/null +++ b/repair_type/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Repair Type", + "version": "19.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/repair", + "summary": "Repair type", + "category": "Repair", + "depends": ["repair"], + "data": [ + "views/stock_picking_type_views.xml", + ], + "installable": True, + "development_status": "Alpha", + "license": "AGPL-3", + "application": False, +} diff --git a/repair_type/i18n/es.po b/repair_type/i18n/es.po new file mode 100644 index 00000000..e187c16c --- /dev/null +++ b/repair_type/i18n/es.po @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-27 15:14+0000\n" +"PO-Revision-Date: 2024-11-27 15:14+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "Default Add Source Location" +msgstr "Ubicación de origen por defecto para añadir" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "Default Recycle Source Location" +msgstr "Ubicación de origen por defecto para reciclaje" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "Default Remove Source Location" +msgstr "Ubicación de origen por defecto para eliminar" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_picking_type +msgid "Picking Type" +msgstr "Tipo de albarán" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de stock" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "" +"This is the default add source location when you create a repair order with " +"this operation type." +msgstr "" +"Esta es la ubicación de origen por defecto para añadir cuando cree una orden " +"de reparación con este tipo de operación." + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "" +"This is the default recycle source location when you create a repair order " +"with this operation type." +msgstr "" +"Esta es la ubicación de origen por defecto para el reciclaje cuando cree una " +"orden de reparación con este tipo de operación." + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "" +"This is the default remove source location when you create a repair order " +"with this operation type." +msgstr "" +"Esta es la ubicación de origen por defecto para eleminar cuando cree una " +"orden de reparación con este tipo de operación." + +#~ msgid "Repair Order" +#~ msgstr "Orden de reparación" diff --git a/repair_type/i18n/hr.po b/repair_type/i18n/hr.po new file mode 100644 index 00000000..6ca0c724 --- /dev/null +++ b/repair_type/i18n/hr.po @@ -0,0 +1,66 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-27 15:16+0000\n" +"PO-Revision-Date: 2024-11-27 15:16+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "Default Add Source Location" +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "Default Recycle Source Location" +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "Default Remove Source Location" +msgstr "" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_picking_type +msgid "Picking Type" +msgstr "Vrsta dokumenta" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_move +msgid "Stock Move" +msgstr "Skladišni prijenos" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "" +"This is the default add source location when you create a repair order with " +"this operation type." +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "" +"This is the default recycle source location when you create a repair order " +"with this operation type." +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "" +"This is the default remove source location when you create a repair order " +"with this operation type." +msgstr "" + +#~ msgid "Repair Order" +#~ msgstr "Nalog za popravak" diff --git a/repair_type/i18n/it.po b/repair_type/i18n/it.po new file mode 100644 index 00000000..b90102fd --- /dev/null +++ b/repair_type/i18n/it.po @@ -0,0 +1,73 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-27 15:17+0000\n" +"PO-Revision-Date: 2024-12-02 10:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: \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_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "Default Add Source Location" +msgstr "Aggiungi ubicazione origine in modo predefinito" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "Default Recycle Source Location" +msgstr "Ricicla ubicazione origine in modo predefinito" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "Default Remove Source Location" +msgstr "Rimuovi ubicazione origine in modo predefinito" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_picking_type +msgid "Picking Type" +msgstr "Tipo prelievo" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_move +msgid "Stock Move" +msgstr "Movimento di magazzino" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "" +"This is the default add source location when you create a repair order with " +"this operation type." +msgstr "" +"Questa è l'ubicazione origine predefinita aggiunta quando si crea un ordine " +"di riparazione con questo tipo operazione." + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "" +"This is the default recycle source location when you create a repair order " +"with this operation type." +msgstr "" +"Questa è l'ubicazione riciclo predefinita aggiunta quando si crea un ordine " +"di riparazione con questo tipo operazione." + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "" +"This is the default remove source location when you create a repair order " +"with this operation type." +msgstr "" +"Questa è l'ubicazione rimozione predefinita aggiunta quando si crea un " +"ordine di riparazione con questo tipo operazione." + +#~ msgid "Repair Order" +#~ msgstr "Ordine di riparazione" diff --git a/repair_type/i18n/repair_type.pot b/repair_type/i18n/repair_type.pot new file mode 100644 index 00000000..e7bfb3b4 --- /dev/null +++ b/repair_type/i18n/repair_type.pot @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "Default Add Source Location" +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "Default Recycle Source Location" +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "Default Remove Source Location" +msgstr "" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_picking_type +msgid "Picking Type" +msgstr "" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_src_id +msgid "" +"This is the default add source location when you create a repair order with " +"this operation type." +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_recycle_location_src_id +msgid "" +"This is the default recycle source location when you create a repair order " +"with this operation type." +msgstr "" + +#. module: repair_type +#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_remove_location_src_id +msgid "" +"This is the default remove source location when you create a repair order " +"with this operation type." +msgstr "" diff --git a/repair_type/models/__init__.py b/repair_type/models/__init__.py new file mode 100644 index 00000000..90f60beb --- /dev/null +++ b/repair_type/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_move +from . import stock_picking_type diff --git a/repair_type/models/stock_move.py b/repair_type/models/stock_move.py new file mode 100644 index 00000000..48111704 --- /dev/null +++ b/repair_type/models/stock_move.py @@ -0,0 +1,58 @@ +# Copyright (C) 2024 APSL-Nagarro Antoni Marroig +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + def _get_repair_locations(self, repair_line_type, repair_id=False): + res = super()._get_repair_locations(repair_line_type, repair_id) + if not repair_id: + if ( + repair_line_type == "add" + and self.repair_id.picking_type_id.default_add_location_src_id + ): + res = ( + self.repair_id.picking_type_id.default_add_location_src_id, + res[1], + ) + elif ( + repair_line_type == "remove" + and self.repair_id.picking_type_id.default_remove_location_src_id + ): + res = ( + self.repair_id.picking_type_id.default_remove_location_src_id, + res[1], + ) + elif ( + repair_line_type == "recycle" + and self.repair_id.picking_type_id.default_recycle_location_src_id + ): + res = ( + self.repair_id.picking_type_id.default_recycle_location_src_id, + res[1], + ) + return res + + def _compute_location_id(self): + ids_to_super = set() + for move in self: + if move.repair_line_type and move.repair_id: + location_src, _ = move._get_repair_locations(move.repair_line_type) + move.location_id = location_src + else: + ids_to_super.add(move.id) + return super(StockMove, self.browse(ids_to_super))._compute_location_id() + + @api.depends("repair_id.location_dest_id", "repair_line_type") + def _compute_location_dest_id(self): + ids_to_super = set() + for move in self: + if move.repair_id and move.repair_line_type: + _, location_dest = move._get_repair_locations(move.repair_line_type) + move.location_dest_id = location_dest + else: + ids_to_super.add(move.id) + return super(StockMove, self.browse(ids_to_super))._compute_location_dest_id() diff --git a/repair_type/models/stock_picking_type.py b/repair_type/models/stock_picking_type.py new file mode 100644 index 00000000..d61c5f21 --- /dev/null +++ b/repair_type/models/stock_picking_type.py @@ -0,0 +1,60 @@ +# Copyright (C) 2024 APSL-Nagarro Antoni Marroig +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models + + +class PickingType(models.Model): + _inherit = "stock.picking.type" + + default_remove_location_src_id = fields.Many2one( + "stock.location", + "Default Remove Source Location", + compute="_compute_default_location_src_id", + check_company=True, + store=True, + readonly=False, + precompute=True, + help="This is the default remove source location when you create a repair " + "order with this operation type.", + ) + default_recycle_location_src_id = fields.Many2one( + "stock.location", + "Default Recycle Source Location", + compute="_compute_default_location_src_id", + check_company=True, + store=True, + readonly=False, + precompute=True, + help="This is the default recycle source location when you create a repair " + "order with this operation type.", + ) + default_add_location_src_id = fields.Many2one( + "stock.location", + "Default Add Source Location", + compute="_compute_default_location_src_id", + check_company=True, + store=True, + readonly=False, + precompute=True, + help="This is the default add source location when you create a repair " + "order with this operation type.", + ) + + @api.depends("code") + def _compute_default_location_src_id(self): + res = super()._compute_default_location_src_id() + for picking_type in self: + stock_location = picking_type.warehouse_id.lot_stock_id + if picking_type.code == "repair_operation": + picking_type.default_add_location_src_id = stock_location.id + prod_location = self.env["stock.location"].search( + [ + ("usage", "=", "production"), + ("company_id", "=", picking_type.company_id.id), + ], + limit=1, + ) + picking_type.default_remove_location_src_id = prod_location.id + picking_type.default_recycle_location_src_id = prod_location.id + return res diff --git a/repair_type/pyproject.toml b/repair_type/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_type/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_type/readme/CONTRIBUTORS.md b/repair_type/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..c1203f25 --- /dev/null +++ b/repair_type/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- [ForgeFlow](https://forgeflow.com): + + > - Bernat Puig \<\> + +- [APSL-Nagarro](https://apsl.tech): + + > - Antoni Marroig \<\> + > - Miquel Alzanillas \<>\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/repair_type/readme/DESCRIPTION.md b/repair_type/readme/DESCRIPTION.md new file mode 100644 index 00000000..95ba524e --- /dev/null +++ b/repair_type/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds support for source locations when adding, removing, or recycling components. If you specify any of these types in a Repair Order, Odoo will automatically apply the corresponding locations from the related stock picking type to the stock moves. \ No newline at end of file diff --git a/repair_type/readme/USAGE.md b/repair_type/readme/USAGE.md new file mode 100644 index 00000000..6228fd88 --- /dev/null +++ b/repair_type/readme/USAGE.md @@ -0,0 +1,2 @@ +- Set the stock picking type for repairs and define source locations for adding, removing and recycling components. +- When you select this stock picking type in a Repair Order, Odoo will automatically assign the specified source locations to the stock moves for the respective components. \ No newline at end of file diff --git a/repair_type/static/description/icon.png b/repair_type/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_type/static/description/icon.png differ diff --git a/repair_type/static/description/index.html b/repair_type/static/description/index.html new file mode 100644 index 00000000..a9389cd0 --- /dev/null +++ b/repair_type/static/description/index.html @@ -0,0 +1,465 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Repair Type

+ +

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

+

This module adds support for source locations when adding, removing, or +recycling components. If you specify any of these types in a Repair +Order, Odoo will automatically apply the corresponding locations from +the related stock picking type to the stock moves.

+
+

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

+ +
+

Usage

+
    +
  • Set the stock picking type for repairs and define source locations for +adding, removing and recycling components.
  • +
  • When you select this stock picking type in a Repair Order, Odoo will +automatically assign the specified source locations to the stock moves +for the respective components.
  • +
+
+
+

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_type/tests/__init__.py b/repair_type/tests/__init__.py new file mode 100644 index 00000000..8e6b3334 --- /dev/null +++ b/repair_type/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from . import test_repair_type diff --git a/repair_type/tests/test_repair_type.py b/repair_type/tests/test_repair_type.py new file mode 100644 index 00000000..800522ea --- /dev/null +++ b/repair_type/tests/test_repair_type.py @@ -0,0 +1,104 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import Command +from odoo.tests.common import TransactionCase + + +class TestRepairType(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.picking_type = cls.env.ref("repair.picking_type_warehouse0_repair") + cls.product_1 = cls.env["product.product"].create( + { + "name": "Test Product 1", + } + ) + cls.product_2 = cls.env["product.product"].create( + { + "name": "Test Product 2", + } + ) + cls.product_3 = cls.env["product.product"].create( + { + "name": "Test Product 3", + } + ) + cls.uom_unit = cls.env.ref("uom.product_uom_unit") + cls.customer_location = cls.env.ref("stock.stock_location_customers") + + def _create_repair_order( + self, + picking_type_ref, + product_ref, + repair_line_type, + product_qty, + component_ref, + ): + """Helper method to create a repair order.""" + return self.env["repair.order"].create( + { + "picking_type_id": picking_type_ref.id, + "product_id": product_ref.id, + "product_uom": self.uom_unit.id, + "move_ids": [ + Command.create( + { + "repair_line_type": repair_line_type, + "product_id": component_ref.id, + "product_uom_qty": product_qty, + } + ), + ], + } + ) + + def _set_default_location(self, location_field, location_ref): + """Helper method to set default locations.""" + self.picking_type[location_field] = location_ref + + def _test_repair_location( + self, repair_line_type, location_field, location_ref, component_ref, product_qty + ): + """Reusable test logic for validating repair locations.""" + self._set_default_location(location_field, location_ref) + repair = self._create_repair_order( + self.picking_type, + self.product_1, + repair_line_type, + product_qty, + component_ref, + ) + repair._action_repair_confirm() + self.assertEqual( + repair.move_ids.move_line_ids.location_id, + location_ref, + ) + + def test_get_repair_locations_remove(self): + self._test_repair_location( + repair_line_type="remove", + location_field="default_remove_location_src_id", + location_ref=self.customer_location, + component_ref=self.product_2, + product_qty=3, + ) + + def test_get_repair_locations_recycle(self): + self._test_repair_location( + repair_line_type="recycle", + location_field="default_recycle_location_src_id", + location_ref=self.customer_location, + component_ref=self.product_3, + product_qty=3, + ) + + def test_get_repair_locations_add(self): + self._test_repair_location( + repair_line_type="add", + location_field="default_add_location_src_id", + location_ref=self.customer_location, + component_ref=self.product_2, + product_qty=5, + ) diff --git a/repair_type/views/stock_picking_type_views.xml b/repair_type/views/stock_picking_type_views.xml new file mode 100644 index 00000000..c873b3b6 --- /dev/null +++ b/repair_type/views/stock_picking_type_views.xml @@ -0,0 +1,42 @@ + + + + stock.picking.type.inherit.repair.type + stock.picking.type + + + + + + + + + + + + + + + +