Skip to content

Commit

Permalink
[MIG] repair_type: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peluko00 committed Jul 15, 2024
1 parent c2b6153 commit 08f7f2b
Show file tree
Hide file tree
Showing 20 changed files with 363 additions and 432 deletions.
32 changes: 13 additions & 19 deletions repair_type/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ Repair Type

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds the type to a repair order. If we select a type on a
Repair Order, Odoo will automatically fill some fields of the order.
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.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -41,26 +43,13 @@ Repair Order, Odoo will automatically fill some fields of the order.
.. contents::
:local:

Configuration
=============

No configuration needed for this module.

Usage
=====

Go to Configuration>Repair Types and create a new repair type.
Afterwards selecting a type on a Repair Order will automatically fill
some fields.

Known issues / Roadmap
======================

Possible improvements for future versions:

- Destination Location of the product to repair is not used currently,
so that's why is invisible. We still save the field for future new
module implementations.
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.

Bug Tracker
===========
Expand All @@ -87,6 +76,11 @@ Contributors

- Bernat Puig <[email protected]>

- `APSL-Nagarro <https://apsl.tech>`__:

- Antoni Marroig <[email protected]>
- Miquel Alzanillas <[email protected]>>

Maintainers
-----------

Expand Down
6 changes: 2 additions & 4 deletions repair_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

{
"name": "Repair Type",
"version": "16.0.1.0.1",
"version": "17.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/repair.xml",
"views/repair_type.xml",
"security/ir.model.access.csv",
"views/stock_picking_type_views.xml",
],
"installable": True,
"development_status": "Alpha",
Expand Down
54 changes: 54 additions & 0 deletions repair_type/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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-06-27 13:31+0000\n"
"PO-Revision-Date: 2024-06-27 13:31+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
#: 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 recolecció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_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."
33 changes: 33 additions & 0 deletions repair_type/migrations/17.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2024 APSL-Nagarro Antoni Marroig
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
INSERT INTO stock_picking_type
(create_date, default_add_location_dest_id, default_remove_location_dest_id,
name,default_add_location_src_id, default_remove_location_src_id)
SELECT create_date, destination_location_add_part_id,
destination_location_remove_part_id, name,
source_location_add_part_id, source_location_remove_part_id
FROM repair_type;
""",
)
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE repair_order
DROP COLUMN repair_type_id;
""",
)
openupgrade.logged_query(
env.cr,
"""
DROP TABLE repair_type;
""",
)
4 changes: 2 additions & 2 deletions repair_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import repair
from . import repair_type
from . import stock_move
from . import stock_picking_type
75 changes: 0 additions & 75 deletions repair_type/models/repair.py

This file was deleted.

36 changes: 0 additions & 36 deletions repair_type/models/repair_type.py

This file was deleted.

37 changes: 37 additions & 0 deletions repair_type/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (C) 2024 APSL-Nagarro Antoni Marroig
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

from odoo import 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 = (

Check warning on line 17 in repair_type/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

repair_type/models/stock_move.py#L17

Added line #L17 was not covered by tests
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
Loading

0 comments on commit 08f7f2b

Please sign in to comment.