Skip to content

Commit

Permalink
[FIX] repair_type: Remove duplicated destination location for added p…
Browse files Browse the repository at this point in the history
…arts and add product destination location
  • Loading branch information
ppyczko committed Nov 26, 2024
1 parent b40101b commit 6d7804b
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 112 deletions.
20 changes: 12 additions & 8 deletions repair_type/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ 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.

Additionally, it adds a default destination location for the repaired
product.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -46,10 +49,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
===========
Expand Down
1 change: 1 addition & 0 deletions repair_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"category": "Repair",
"depends": ["repair"],
"data": [
"views/repair_views.xml",
"views/stock_picking_type_views.xml",
],
"installable": True,
Expand Down
54 changes: 36 additions & 18 deletions repair_type/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@ 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-21 09:04+0000\n"
"PO-Revision-Date: 2024-11-21 09:04+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_product_location_dest_id
msgid "Default Product Destination Location"
msgstr "Ubicación de destino del producto por defecto"

#. module: repair_type
#: model:ir.model.fields,field_description:repair_type.field_stock_picking_type__default_recycle_location_src_id
Expand All @@ -39,35 +38,49 @@ 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.fields,field_description:repair_type.field_repair_order__product_location_dest_id
msgid "Product Destination Location"
msgstr "Ubicación de destino del producto"

#. 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
#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_add_location_src_id
msgid ""
"This is the default add destination location when you create a repair order "
"with this operation type."
"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_add_location_src_id
#: model:ir.model.fields,help:repair_type.field_stock_picking_type__default_product_location_dest_id
msgid ""
"This is the default add source location when you create a repair order with "
"this operation type."
"This is the default product destination location when you create a repair "
"order with this operation type."
msgstr ""
"Esta es la ubicación de destino del producto por defecto 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."
"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
Expand All @@ -77,3 +90,8 @@ msgid ""
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."

#. module: repair_type
#: model:ir.model.fields,help:repair_type.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."
1 change: 1 addition & 0 deletions repair_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import repair
from . import stock_move
from . import stock_picking_type
28 changes: 28 additions & 0 deletions repair_type/models/repair.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Patryk Pyczko (APSL-Nagarro)<[email protected]>
# 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,
readonly=False,
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
)
2 changes: 1 addition & 1 deletion repair_type/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 8 additions & 21 deletions repair_type/models/stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ 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(
default_product_location_dest_id = fields.Many2one(
"stock.location",
"Default Add Destination Location",
compute="_compute_default_location_dest_id",
"Default Product Destination Location",
compute="_compute_default_location_src_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.",
help="This is the default product destination location when you create a "
"repair order with this operation type.",
)

@api.depends("code")
Expand All @@ -59,20 +59,7 @@ 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
picking_type.default_product_location_dest_id = stock_location.id
return res
4 changes: 3 additions & 1 deletion repair_type/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
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.

Additionally, it adds a default destination location for the repaired product.
4 changes: 2 additions & 2 deletions repair_type/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 13 additions & 8 deletions repair_type/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,12 @@ <h1 class="title">Repair Type</h1>
!! source digest: sha256:4bc94fb9082c60cda55c55f3f7a252f12eff375a752e9a1dc186d8345ddeeec0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/repair/tree/17.0/repair_type"><img alt="OCA/repair" src="https://img.shields.io/badge/github-OCA%2Frepair-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/repair-17-0/repair-17-0-repair_type"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/repair&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
<p>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.</p>
<p>Additionally, it adds a default destination location for the repaired
product.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -395,10 +397,13 @@ <h1 class="title">Repair Type</h1>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>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.</p>
<ul class="simple">
<li>Set the stock picking type for repairs and define source locations
for adding, removing and recycling components.</li>
<li>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.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand Down
Loading

0 comments on commit 6d7804b

Please sign in to comment.