diff --git a/repair_type/README.rst b/repair_type/README.rst index ebc571ff..a7a8138e 100644 --- a/repair_type/README.rst +++ b/repair_type/README.rst @@ -28,10 +28,10 @@ Repair Type |badge1| |badge2| |badge3| |badge4| |badge5| -This module adds the source location from removing and recycling -components. If we select the both locations on stock picking type when -you select that in a Repair Order, Odoo will automatically set that in -stock moves for that components. +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. @@ -46,10 +46,11 @@ stock moves for that components. Usage ===== -Set stock picking type for repairs and select source locations for -removing and recycling components. Afterwards selecting that stock -picking type on a Repair Order will automatically put that source -location on stock moves of that components. +- 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 =========== diff --git a/repair_type/i18n/es.po b/repair_type/i18n/es.po index 8ba5fb00..44248e9e 100644 --- a/repair_type/i18n/es.po +++ b/repair_type/i18n/es.po @@ -6,25 +6,19 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-27 13:31+0000\n" -"PO-Revision-Date: 2024-06-27 13:31+0000\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_dest_id -msgid "Default Add Destination Location" -msgstr "" - #. 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 "" +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 @@ -39,26 +33,26 @@ 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 recolección" +msgstr "Tipo de albarán" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_repair_order +msgid "Repair Order" +msgstr "Orden de reparació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_dest_id -msgid "" -"This is the default add destination 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_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 @@ -66,8 +60,8 @@ 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." +"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 diff --git a/repair_type/i18n/hr.po b/repair_type/i18n/hr.po index 6297e49e..0340dd67 100644 --- a/repair_type/i18n/hr.po +++ b/repair_type/i18n/hr.po @@ -4,23 +4,16 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2022-08-22 14:07+0000\n" -"Last-Translator: Bole \n" -"Language-Team: none\n" -"Language: hr\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" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " -"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.3.2\n" - -#. module: repair_type -#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_dest_id -msgid "Default Add Destination Location" -msgstr "" +"Plural-Forms: \n" #. module: repair_type #: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_src_id @@ -40,19 +33,17 @@ msgstr "" #. module: repair_type #: model:ir.model,name:repair_type.model_stock_picking_type msgid "Picking Type" -msgstr "" +msgstr "Vrsta dokumenta" #. module: repair_type -#: model:ir.model,name:repair_type.model_stock_move -msgid "Stock Move" -msgstr "" +#: model:ir.model,name:repair_type.model_repair_order +msgid "Repair Order" +msgstr "Nalog za popravak" #. module: repair_type -#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_dest_id -msgid "" -"This is the default add destination location when you create a repair order " -"with this operation type." -msgstr "" +#: 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 @@ -74,57 +65,3 @@ msgid "" "This is the default remove source location when you create a repair order " "with this operation type." msgstr "" - -#~ msgid "Created by" -#~ msgstr "Kreirao" - -#~ msgid "Created on" -#~ msgstr "Kreirano" - -#~ msgid "Dest. Location" -#~ msgstr "Odredišna lokacija" - -#~ msgid "Destination Location Add Component" -#~ msgstr "Dodaj komponentu na odredišnu lokaciju" - -#~ msgid "Destination Location Remove Component" -#~ msgstr "Ukloni komponentu sa odredišne lokacije" - -#~ msgid "Display Name" -#~ msgstr "Naziv" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Zadnje modificirano" - -#~ msgid "Last Updated by" -#~ msgstr "Zadnje ažurirano" - -#~ msgid "Location" -#~ msgstr "Lokacija" - -#~ msgid "Repair Line (parts)" -#~ msgstr "Stavka popravka (dijelovi)" - -#~ msgid "Repair Order" -#~ msgstr "Nalog za popravak" - -#~ msgid "Repair Type" -#~ msgstr "Vrsta popravka" - -#~ msgid "Repair Type Name" -#~ msgstr "Naziv vrste popravka" - -#~ msgid "Repair Types" -#~ msgstr "Vrste popravaka" - -#~ msgid "Repair types" -#~ msgstr "Vrste popravaka" - -#~ msgid "Source Location" -#~ msgstr "Izvorišna lokacija" - -#~ msgid "Destination Location" -#~ msgstr "Odredišna lokacija" diff --git a/repair_type/i18n/it.po b/repair_type/i18n/it.po index 70cf9024..f19971ec 100644 --- a/repair_type/i18n/it.po +++ b/repair_type/i18n/it.po @@ -4,22 +4,16 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2024-08-22 10:06+0000\n" -"Last-Translator: mymage \n" -"Language-Team: none\n" -"Language: it\n" +"POT-Creation-Date: 2024-11-27 15:17+0000\n" +"PO-Revision-Date: 2024-11-27 15:17+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: 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_dest_id -msgid "Default Add Destination Location" -msgstr "Aggiungi ubicazione destinazione in modo predefinito" +"Plural-Forms: \n" #. module: repair_type #: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_add_location_src_id @@ -39,22 +33,18 @@ 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" +msgstr "Tipologia prelievo" + +#. module: repair_type +#: model:ir.model,name:repair_type.model_repair_order +msgid "Repair Order" +msgstr "Ordine di riparazione" #. 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_dest_id -msgid "" -"This is the default add destination location when you create a repair order " -"with this operation type." -msgstr "" -"Questa è la destinazione predefinita aggiunta quando si crea un ordine di " -"riparazione con questo tipo di operazione." - #. module: repair_type #: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_src_id msgid "" @@ -81,78 +71,3 @@ msgid "" msgstr "" "Questa è l'ubicazione rimozione predefinita aggiunta quando si crea un " "ordine di riparazione con questo tipo operazione." - -#~ msgid "Created by" -#~ msgstr "Creato da" - -#~ msgid "Created on" -#~ msgstr "Creato il" - -#~ msgid "Dest. Location" -#~ msgstr "Ubicazione dest." - -#~ msgid "Destination Location Add Component" -#~ msgstr "Aggiungi componente ubicazione destinazione" - -#~ msgid "Destination Location Remove Component" -#~ msgstr "Rimuovi componente ubicazione destinazione" - -#~ msgid "Display Name" -#~ msgstr "Nome visualizzato" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Ultima modifica il" - -#~ msgid "Last Updated by" -#~ msgstr "Ultimo aggiornamento di" - -#~ msgid "Last Updated on" -#~ msgstr "Ultimo aggiornamento il" - -#~ msgid "Location" -#~ msgstr "Ubicazione" - -#~ msgid "Repair Line (parts)" -#~ msgstr "Riga riparazione (componenti)" - -#~ msgid "Repair Order" -#~ msgstr "Ordine di riparazione" - -#~ msgid "Repair Type" -#~ msgstr "Tipo riparazione" - -#~ msgid "Repair Type Name" -#~ msgstr "Nome tipo riparazione" - -#~ msgid "Repair Types" -#~ msgstr "Tipi riparazione" - -#~ msgid "Repair types" -#~ msgstr "Tipi riparazione" - -#~ msgid "Source Location" -#~ msgstr "Ubicazione di origine" - -#~ msgid "Source Location Add Component" -#~ msgstr "Aggiungi componente ubicazione origine" - -#~ msgid "Source Location Remove Component" -#~ msgstr "Rimuovi componente ubicazione origine" - -#~ msgid "" -#~ "This is the location where the part of the product to add is located." -#~ msgstr "" -#~ "Questa è l'ubicazione dove si trova il componenti del prodotto da " -#~ "aggiungere." - -#~ msgid "" -#~ "This is the location where the part of the product to remove is located." -#~ msgstr "" -#~ "Questa è l'ubicazione dove si trava il componente del prodotto da " -#~ "rimuovere." - -#~ msgid "This is the location where the product to repair is located." -#~ msgstr "Questa è l'ubicazione dove si trova il prodotto da riparare." diff --git a/repair_type/i18n/repair_type.pot b/repair_type/i18n/repair_type.pot index 45ec3d8f..cd5b1714 100644 --- a/repair_type/i18n/repair_type.pot +++ b/repair_type/i18n/repair_type.pot @@ -6,6 +6,8 @@ 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" "MIME-Version: 1.0\n" @@ -13,11 +15,6 @@ msgstr "" "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_dest_id -msgid "Default Add Destination Location" -msgstr "" - #. 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" @@ -39,15 +36,13 @@ msgid "Picking Type" msgstr "" #. module: repair_type -#: model:ir.model,name:repair_type.model_stock_move -msgid "Stock Move" +#: model:ir.model,name:repair_type.model_repair_order +msgid "Repair Order" msgstr "" #. module: repair_type -#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_dest_id -msgid "" -"This is the default add destination location when you create a repair order " -"with this operation type." +#: model:ir.model,name:repair_type.model_stock_move +msgid "Stock Move" msgstr "" #. module: repair_type diff --git a/repair_type/models/stock_move.py b/repair_type/models/stock_move.py index 5a4e21ff..dce15de8 100644 --- a/repair_type/models/stock_move.py +++ b/repair_type/models/stock_move.py @@ -16,7 +16,7 @@ def _get_repair_locations(self, repair_line_type, repair_id=False): ): res = ( self.repair_id.picking_type_id.default_add_location_src_id, - self.repair_id.picking_type_id.default_add_location_dest_id, + res[1], ) elif ( repair_line_type == "remove" diff --git a/repair_type/models/stock_picking_type.py b/repair_type/models/stock_picking_type.py index 1692ce40..140a155e 100644 --- a/repair_type/models/stock_picking_type.py +++ b/repair_type/models/stock_picking_type.py @@ -40,17 +40,6 @@ class PickingType(models.Model): help="This is the default add source location when you create a repair " "order with this operation type.", ) - default_add_location_dest_id = fields.Many2one( - "stock.location", - "Default Add Destination Location", - compute="_compute_default_location_dest_id", - check_company=True, - store=True, - readonly=False, - precompute=True, - help="This is the default add destination location when you create a repair " - "order with this operation type.", - ) @api.depends("code") def _compute_default_location_src_id(self): @@ -59,20 +48,6 @@ def _compute_default_location_src_id(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 - return res - - @api.depends("code") - def _compute_default_location_dest_id(self): - res = super()._compute_default_location_dest_id() - for picking_type in self: - if picking_type.code == "repair_operation": - picking_type.default_add_location_dest_id = ( - picking_type.default_location_dest_id.id - ) - picking_type.default_remove_location_src_id = ( - picking_type.default_location_dest_id.id - ) - picking_type.default_recycle_location_src_id = ( - picking_type.default_location_dest_id.id - ) + picking_type.default_remove_location_src_id = stock_location.id + picking_type.default_recycle_location_src_id = stock_location.id return res diff --git a/repair_type/readme/DESCRIPTION.md b/repair_type/readme/DESCRIPTION.md index 07652c6c..95ba524e 100644 --- a/repair_type/readme/DESCRIPTION.md +++ b/repair_type/readme/DESCRIPTION.md @@ -1 +1 @@ -This module adds the source location from removing and recycling components. If we select the both locations on stock picking type when you select that in a Repair Order, Odoo will automatically set that in stock moves for that components. +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 index 931cc1ad..6228fd88 100644 --- a/repair_type/readme/USAGE.md +++ b/repair_type/readme/USAGE.md @@ -1,2 +1,2 @@ -Set stock picking type for repairs and select source locations for removing and recycling components. -Afterwards selecting that stock picking type on a Repair Order will automatically put that source location on stock moves of that components. +- 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/index.html b/repair_type/static/description/index.html index 87cda517..f2509d6e 100644 --- a/repair_type/static/description/index.html +++ b/repair_type/static/description/index.html @@ -370,10 +370,10 @@

Repair Type

!! source digest: sha256:4bc94fb9082c60cda55c55f3f7a252f12eff375a752e9a1dc186d8345ddeeec0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

-

This module adds the source location from removing and recycling -components. If we select the both locations on stock picking type when -you select that in a Repair Order, Odoo will automatically set that in -stock moves for that components.

+

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. @@ -395,10 +395,13 @@

Repair Type

Usage

-

Set stock picking type for repairs and select source locations for -removing and recycling components. Afterwards selecting that stock -picking type on a Repair Order will automatically put that source -location on stock moves of that components.

+
    +
  • 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

diff --git a/repair_type/tests/test_repair_type.py b/repair_type/tests/test_repair_type.py index 2e803295..aa235f29 100644 --- a/repair_type/tests/test_repair_type.py +++ b/repair_type/tests/test_repair_type.py @@ -5,68 +5,90 @@ class TestRepairType(TransactionCase): - def test_get_repair_locations_remove(self): - self.env.ref( - "repair.picking_type_warehouse0_repair" - ).default_remove_location_src_id = self.env.ref( - "stock.stock_location_customers" - ) - repair = self.env["repair.order"].create( + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.picking_type = cls.env.ref("repair.picking_type_warehouse0_repair") + cls.product_4 = cls.env.ref("product.product_product_4") + cls.product_3 = cls.env.ref("product.product_product_3") + cls.product_11 = cls.env.ref("product.product_product_11") + 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": self.env.ref( - "repair.picking_type_warehouse0_repair" - ).id, - "product_id": self.env.ref("product.product_product_4").id, - "product_uom": self.env.ref("uom.product_uom_unit").id, + "picking_type_id": picking_type_ref.id, + "product_id": product_ref.id, + "product_uom": self.uom_unit.id, "move_ids": [ ( 0, 0, { - "name": "Remove Component 1", - "repair_line_type": "remove", - "product_id": self.env.ref("product.product_product_3").id, - "product_uom_qty": 3, + "name": f"{repair_line_type.capitalize()} Component", + "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_4, + repair_line_type, + product_qty, + component_ref, + ) repair._action_repair_confirm() self.assertEqual( repair.move_ids.move_line_ids.location_id, - self.env.ref("stock.stock_location_customers"), + location_ref, ) - def test_get_repair_locations_recycle(self): - self.env.ref( - "repair.picking_type_warehouse0_repair" - ).default_recycle_location_src_id = self.env.ref( - "stock.stock_location_customers" + 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_3, + product_qty=3, ) - repair = self.env["repair.order"].create( - { - "picking_type_id": self.env.ref( - "repair.picking_type_warehouse0_repair" - ).id, - "product_id": self.env.ref("product.product_product_4").id, - "product_uom": self.env.ref("uom.product_uom_unit").id, - "move_ids": [ - ( - 0, - 0, - { - "name": "Recycle Component", - "repair_line_type": "recycle", - "product_uom_qty": 3, - "product_id": self.env.ref("product.product_product_11").id, - }, - ) - ], - } + + 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_11, + product_qty=3, ) - repair._action_repair_confirm() - self.assertEqual( - repair.move_ids.move_line_ids.location_id, - self.env.ref("stock.stock_location_customers"), + + 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_3, + product_qty=5, ) diff --git a/repair_type/views/stock_picking_type_views.xml b/repair_type/views/stock_picking_type_views.xml index 2f384711..c873b3b6 100644 --- a/repair_type/views/stock_picking_type_views.xml +++ b/repair_type/views/stock_picking_type_views.xml @@ -5,21 +5,19 @@ stock.picking.type - + + + + +