Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][14.0][ADD] rma_repair #1

Open
wants to merge 3 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions rma_repair/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
==========
RMA Repair
==========

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c7d5c60d257fb2ee1f19f0e09776496931d127b544dd2d50c82690023d48b37c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |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%2Frma-lightgray.png?logo=github
:target: https://github.com/OCA/rma/tree/14.0/rma_repair
:alt: OCA/rma
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rma-14-0/rma-14-0-rma_repair
: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/rma&target_branch=14.0
:alt: Try me on Runboat

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

Allows to link RMA with repair orders.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/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 <https://github.com/OCA/rma/issues/new?body=module:%20rma_repair%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* NuoBiT Solutions
* S.L.

Contributors
~~~~~~~~~~~~

* `Nuobit <https://www.nuobit.com>`_:

* Frank Cespedes <[email protected]>

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/rma <https://github.com/OCA/rma/tree/14.0/rma_repair>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions rma_repair/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
19 changes: 19 additions & 0 deletions rma_repair/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "RMA Repair",
"summary": "Allows to link RMA with repair orders",
"version": "14.0.0.0.0",
"development_status": "Production/Stable",
"category": "RMA",
"website": "https://github.com/OCA/rma",
"author": "NuoBiT Solutions, S.L., Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["rma", "repair"],
"data": [
"security/ir.model.access.csv",
"views/repair_views.xml",
"wizards/rma_repair_wizard_views.xml",
"views/rma_views.xml",
],
}
220 changes: 220 additions & 0 deletions rma_repair/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rma_repair
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-04 14:06+0000\n"
"PO-Revision-Date: 2024-06-04 14:06+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: rma_repair
#: model:ir.model.fields.selection,name:rma_repair.selection__rma_repair_line_wizard__invoice_method__after_repair
msgid "After Repair"
msgstr "Después de Reparar"

#. module: rma_repair
#: model:ir.model.fields.selection,name:rma_repair.selection__rma_repair_line_wizard__invoice_method__b4repair
msgid "Before Repair"
msgstr "Antes de Reparar"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma__can_create_repair_order
msgid "Can Create Repair Order"
msgstr "Puede Crear Orden de Reparación"

#. module: rma_repair
#: model_terms:ir.ui.view,arch_db:rma_repair.rma_repair_wizard_view_form
msgid "Cancel"
msgstr "Cancelar"

#. module: rma_repair
#: model:ir.actions.act_window,name:rma_repair.rma_action_repair
#: model_terms:ir.ui.view,arch_db:rma_repair.rma_repair_wizard_view_form
#: model_terms:ir.ui.view,arch_db:rma_repair.rma_view_form
msgid "Create Repair Order"
msgstr "Crear orden de reparación"

#. module: rma_repair
#: model_terms:ir.ui.view,arch_db:rma_repair.rma_repair_wizard_view_form
msgid "Create Repair Orders"
msgstr "Crear órdenes de reparación"

#. module: rma_repair
#: model_terms:ir.ui.view,arch_db:rma_repair.rma_repair_wizard_view_form
msgid "Create Repair Orders and Block RMA"
msgstr "Crear órdenes de reparación y bloquear RMA"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__create_uid
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__create_uid
msgid "Created by"
msgstr "Creado por"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__create_date
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__create_date
msgid "Created on"
msgstr "Creado el"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_repair_order__display_name
#: model:ir.model.fields,field_description:rma_repair.field_rma__display_name
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__display_name
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__has_lots
msgid "Has Lots"
msgstr "Tiene lotes"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__invoice_method
msgid "Invoice Method"
msgstr "Método de Facturación"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_repair_order____last_update
#: model:ir.model.fields,field_description:rma_repair.field_rma____last_update
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard____last_update
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__write_uid
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__write_uid
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__write_date
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__write_date
msgid "Last Updated on"
msgstr "Última actualización el"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__line_ids
msgid "Line"
msgstr "Línea"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__lot_ids
msgid "Lot"
msgstr "Lote"

#. module: rma_repair
#: model:ir.model.fields.selection,name:rma_repair.selection__rma_repair_line_wizard__invoice_method__none
msgid "No Invoice"
msgstr "Sin factura"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__partner_id
msgid "Partner"
msgstr "Cliente"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__product_id
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_wizard__product_id
msgid "Product"
msgstr "Producto"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma__product_qty_in_repair
msgid "Product Qty In Repair"
msgstr "Cant. de producto en reparación"

#. module: rma_repair
#: code:addons/rma_repair/wizards/rma_repair_wizard.py:0
#, python-format
msgid "Quantity must be positive."
msgstr "La cantidad debe ser positiva."

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__product_qty
msgid "Quantity to repair"
msgstr "Cantidad a reparar"

#. module: rma_repair
#: model:ir.model,name:rma_repair.model_rma_repair_line_wizard
msgid "RMA Repair Line Wizard"
msgstr "RMA Asistente de Línea de Reparación"

#. module: rma_repair
#: model:ir.model,name:rma_repair.model_rma_repair_wizard
msgid "RMA Repair Wizard"
msgstr "Asistente de reparación de RMA"

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma__repair_count
msgid "Repair Count"
msgstr "Conteo de reparaciones"

#. module: rma_repair
#: code:addons/rma_repair/wizards/rma_repair_wizard.py:0
#: model:ir.model,name:rma_repair.model_repair_order
#: model:ir.model.fields,field_description:rma_repair.field_rma__repair_order_ids
#, python-format
msgid "Repair Order"
msgstr "Orden de reparación"

#. module: rma_repair
#: model_terms:ir.ui.view,arch_db:rma_repair.rma_view_form
msgid "Repair Orders"
msgstr "Órdenes de reparación"

#. module: rma_repair
#: model:ir.model.fields,help:rma_repair.field_rma_repair_line_wizard__invoice_method
msgid ""
"Selecting 'Before Repair' or 'After Repair' will allow you to generate "
"invoice before or after the repair is done respectively. 'No invoice' means "
"you don't want to generate invoice for this repair order."
msgstr ""
"Seleccionando 'Antes de reparar' o 'Después de reparar' permitirá generar "
"las facturas antes o después de que se realice la reparación "
"respectivamente. 'Sin factura' significa que no quiere generar factura para "
"esta orden de reparación."

#. module: rma_repair
#: code:addons/rma_repair/wizards/rma_repair_wizard.py:0
#, python-format
msgid "The expected model for this action is 'rma', not '%s'."
msgstr "El modelo esperado para esta acción es 'rma', no '%s'."

#. module: rma_repair
#: code:addons/rma_repair/wizards/rma_repair_wizard.py:0
#, python-format
msgid ""
"Total quantity to repair must be less than or equal to the RMA quantity."
msgstr ""
"La cantidad total a reparar debe ser menor o igual a la cantidad de RMA."

#. module: rma_repair
#: model:ir.model.fields,field_description:rma_repair.field_rma_repair_line_wizard__wizard_id
msgid "Wizard"
msgstr "Asistente"

#. module: rma_repair
#: code:addons/rma_repair/wizards/rma_repair_wizard.py:0
#, python-format
msgid "You already have a repair order for the lot [%s]."
msgstr "Ya tiene una orden de reparación para el lote [%s]."

#. module: rma_repair
#: code:addons/rma_repair/models/rma.py:0
#, python-format
msgid ""
"You can't return to the partner products that are under repair. Please check"
" the products to be repaired."
msgstr ""
"No puede devolver al cliente productos que están en reparación. Por favor, "
"verifique los productos a reparar."
2 changes: 2 additions & 0 deletions rma_repair/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import rma
from . import repair_order
12 changes: 12 additions & 0 deletions rma_repair/models/repair_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class RepairOrder(models.Model):
_inherit = "repair.order"

rma_id = fields.Many2one(
comodel_name="rma", string="RMA", readonly=True, ondelete="restrict"
)
58 changes: 58 additions & 0 deletions rma_repair/models/rma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


from odoo import _, fields, models
from odoo.exceptions import UserError


class Rma(models.Model):
_inherit = "rma"

repair_order_ids = fields.One2many(
comodel_name="repair.order",
inverse_name="rma_id",
readonly=True,
copy=False,
)
repair_count = fields.Integer(compute="_compute_repair_count")

def _compute_repair_count(self):
for rma in self:
rma.repair_count = len(rma.repair_order_ids)

product_qty_in_repair = fields.Float(compute="_compute_product_qty_in_repair")

def _compute_product_qty_in_repair(self):
for rec in self:
rec.product_qty_in_repair = sum(rec.repair_order_ids.mapped("product_qty"))

can_create_repair_order = fields.Boolean(compute="_compute_can_create_repair_order")

def _compute_can_create_repair_order(self):
for rec in self:
rec.can_create_repair_order = (
rec.can_be_returned and rec.product_qty_in_repair < rec.product_uom_qty
)

def _ensure_qty_to_return(self, qty=None, uom=None):
super()._ensure_qty_to_return(qty, uom)
if qty and uom:
under_repair_qty = sum(
self.repair_order_ids.filtered(lambda x: x.state != "done").mapped(
"product_qty"
)
)
if qty > (self.product_uom_qty - under_repair_qty):
raise UserError(
_(
"You can't return to the partner products that are under repair. "
"Please check the products to be repaired."
)
)

def action_view_repair_order(self):
action = self.env.ref("repair.action_repair_order_tree")
result = action.sudo().read()[0]
result["domain"] = [("id", "in", self.repair_order_ids.ids)]
return result
Loading