[FIX] rma_sale_mrp: handle exceptions when qty is forced

This commit is contained in:
david
2021-04-22 11:19:25 +02:00
committed by Víctor Martínez
parent 5cec21aca8
commit d09a5e2cb0
7 changed files with 162 additions and 30 deletions

View File

@@ -3,7 +3,7 @@
{
"name": "Return Merchandise Authorization Management - Link with MRP Kits",
"summary": "Allow doing RMAs from MRP kits",
"version": "12.0.1.0.1",
"version": "12.0.1.0.2",
"development_status": "Beta",
"category": "RMA",
"website": "https://github.com/OCA/rma",

View File

@@ -10,32 +10,72 @@ msgstr ""
"PO-Revision-Date: 2021-01-22 14:44+0100\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: es\n"
"X-Generator: Poedit 2.3\n"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-times\"/> Cancelled</span>"
msgstr "<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-times\"/>Cancelado</span>"
msgid ""
"<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-"
"times\"/> Cancelled</span>"
msgstr ""
"<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-"
"times\"/>Cancelado</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Draft</span>"
msgstr "<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Borrador</span>"
msgid ""
"<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Draft</span>"
msgstr ""
"<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Borrador</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Waiting</span>"
msgstr "<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> En espera</span>"
msgid ""
"<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Waiting</span>"
msgstr ""
"<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> En espera</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<span>Product</span>"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<span>Quantity</span>"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<span>RMA</span>"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<span>State</span>"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<strong class=\"d-block mb-1\">Related Kit Components RMAs</strong>"
msgstr "<strong class=\"d-block mb-1\">RMAs relacionados de los componentes del kit</strong>"
msgstr ""
"<strong class=\"d-block mb-1\">RMAs relacionados de los componentes del kit</"
"strong>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<strong class=\"d-block mt32 mb-1\">Kit information</strong>"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
@@ -47,6 +87,16 @@ msgstr "<strong><i class=\"fa fa-th-large text-info\"/> Ctd. de kits</strong>"
msgid "<strong><i class=\"fa fa-th-large text-info\"/> Kit</strong>"
msgstr "<strong><i class=\"fa fa-th-large text-info\"/> Kit</strong>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<strong>Kit Quantity:</strong>"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<strong>Kit:</strong>"
msgstr ""
#. module: rma_sale_mrp
#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component__allowed_picking_ids
msgid "Allowed Picking"
@@ -69,8 +119,13 @@ msgstr "Líneas de componentes"
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_sale_order_line_rma_wizard_component__uom_category_id
msgid "Conversion between Units of Measure can only occur if they belong to the same category. The conversion will be made based on the ratios."
msgstr "La conversión entre las unidades de medidas sólo pueden ocurrir si pertenecen a la misma categoría. La conversión se basará en los ratios establecidos."
msgid ""
"Conversion between Units of Measure can only occur if they belong to the "
"same category. The conversion will be made based on the ratios."
msgstr ""
"La conversión entre las unidades de medidas sólo pueden ocurrir si "
"pertenecen a la misma categoría. La conversión se basará en los ratios "
"establecidos."
#. module: rma_sale_mrp
#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component__create_uid
@@ -102,6 +157,11 @@ msgstr "Nombre mostrado"
msgid "ID"
msgstr ""
#. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_account_invoice
msgid "Invoice"
msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_my_rmas
msgid "Kit"
@@ -216,10 +276,22 @@ msgstr "Asistente de Orden de Venta - RMA"
msgid "Sales Order Line"
msgstr "Línea de pedido de venta"
#. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:55
#, python-format
msgid ""
"The kit corresponding to the product %s can't be put in the RMA. Either all "
"or some of the components where already put in another RMA"
msgstr ""
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_rma__kit_qty
msgid "To how many kits this components corresponds to. Used mainly for refunding the right quantity"
msgstr "A cuántos kits corresponde este componente. Utilizado principalmente para reembolsar la cantidad correcta"
msgid ""
"To how many kits this components corresponds to. Used mainly for refunding "
"the right quantity"
msgstr ""
"A cuántos kits corresponde este componente. Utilizado principalmente para "
"reembolsar la cantidad correcta"
#. module: rma_sale_mrp
#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component__uom_id
@@ -235,7 +307,9 @@ msgstr "Utilizado para ocultar los componentes en los asistentes"
#: model:ir.model.fields,help:rma_sale_mrp.field_sale_order_line_rma_wizard__kit_qty_done
#: model:ir.model.fields,help:rma_sale_mrp.field_sale_order_line_rma_wizard_component__kit_qty_done
msgid "Used to inform kit qty used in the rma. Will be useful to refund"
msgstr "Utilizado para informar la cantidad de kits utilizados en el RMA. Resultará útil al reembolsar"
msgstr ""
"Utilizado para informar la cantidad de kits utilizados en el RMA. Resultará "
"útil al reembolsar"
#. module: rma_sale_mrp
#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component__wizard_id

View File

@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rma_sale_mrp
# * rma_sale_mrp
#
msgid ""
msgstr ""
@@ -18,21 +18,27 @@ msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-times\"/> Cancelled</span>"
msgid ""
"<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-"
"times\"/> Cancelled</span>"
msgstr ""
"<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-"
"times\"/> Cancelado</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Draft</span>"
msgid ""
"<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Draft</span>"
msgstr ""
"<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Rascunho</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Waiting</span>"
msgid ""
"<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Waiting</span>"
msgstr ""
"<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Em Espera</span>"
@@ -110,7 +116,9 @@ msgstr ""
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_sale_order_line_rma_wizard_component__uom_category_id
msgid "Conversion between Units of Measure can only occur if they belong to the same category. The conversion will be made based on the ratios."
msgid ""
"Conversion between Units of Measure can only occur if they belong to the "
"same category. The conversion will be made based on the ratios."
msgstr ""
#. module: rma_sale_mrp
@@ -262,9 +270,19 @@ msgstr "Assistente da RMA da Encomenda de Venda"
msgid "Sales Order Line"
msgstr "Linha de Encomenda de Venda"
#. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:55
#, python-format
msgid ""
"The kit corresponding to the product %s can't be put in the RMA. Either all "
"or some of the components where already put in another RMA"
msgstr ""
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_rma__kit_qty
msgid "To how many kits this components corresponds to. Used mainly for refunding the right quantity"
msgid ""
"To how many kits this components corresponds to. Used mainly for refunding "
"the right quantity"
msgstr ""
#. module: rma_sale_mrp

View File

@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rma_sale_mrp
# * rma_sale_mrp
#
msgid ""
msgstr ""
@@ -18,21 +18,27 @@ msgstr ""
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-times\"/> Cancelled</span>"
msgid ""
"<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-"
"times\"/> Cancelled</span>"
msgstr ""
"<span class=\"badge badge-danger label-text-align\"><i class=\"fa fa-fw fa-"
"times\"/> Cancelado</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Draft</span>"
msgid ""
"<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Draft</span>"
msgstr ""
"<span class=\"badge badge-info label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Rascunho</span>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page
msgid "<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-clock-o\"/> Waiting</span>"
msgid ""
"<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Waiting</span>"
msgstr ""
"<span class=\"badge badge-warning label-text-align\"><i class=\"fa fa-fw fa-"
"clock-o\"/> Esperando</span>"
@@ -62,8 +68,8 @@ msgstr "<span>Estado</span>"
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
msgid "<strong class=\"d-block mb-1\">Related Kit Components RMAs</strong>"
msgstr ""
"<strong class=\"d-block mb-1\">RMAs de componentes de kit "
"relacionados</strong>"
"<strong class=\"d-block mb-1\">RMAs de componentes de kit relacionados</"
"strong>"
#. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.report_rma_document
@@ -113,7 +119,9 @@ msgstr "Linhas Componentes"
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_sale_order_line_rma_wizard_component__uom_category_id
msgid "Conversion between Units of Measure can only occur if they belong to the same category. The conversion will be made based on the ratios."
msgid ""
"Conversion between Units of Measure can only occur if they belong to the "
"same category. The conversion will be made based on the ratios."
msgstr ""
"Uma conversão entre unidades de medida só poderá ocorrer se pertencer à "
"mesma categoria. A conversão será feita com base nas proporções."
@@ -267,9 +275,19 @@ msgstr "Assistente do Pedido de Venda RMA"
msgid "Sales Order Line"
msgstr "Linha do Pedido de Venda"
#. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:55
#, python-format
msgid ""
"The kit corresponding to the product %s can't be put in the RMA. Either all "
"or some of the components where already put in another RMA"
msgstr ""
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_rma__kit_qty
msgid "To how many kits this components corresponds to. Used mainly for refunding the right quantity"
msgid ""
"To how many kits this components corresponds to. Used mainly for refunding "
"the right quantity"
msgstr ""
"A quantos kits este componente corresponde. Usado principalmente para "
"reembolsar a quantidade certa"

View File

@@ -253,6 +253,12 @@ msgstr ""
msgid "Sales Order Line"
msgstr ""
#. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:55
#, python-format
msgid "The kit corresponding to the product %s can't be put in the RMA. Either all or some of the components where already put in another RMA"
msgstr ""
#. module: rma_sale_mrp
#: model:ir.model.fields,help:rma_sale_mrp.field_rma__kit_qty
msgid "To how many kits this components corresponds to. Used mainly for refunding the right quantity"

View File

@@ -1,7 +1,7 @@
# Copyright 2020 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests import Form, SavepointCase
from odoo.exceptions import UserError
from odoo.exceptions import UserError, ValidationError
class TestRmaSaleMrp(SavepointCase):
@@ -153,3 +153,12 @@ class TestRmaSaleMrp(SavepointCase):
wizard_id = order.action_create_rma()["res_id"]
wizard = self.env["sale.order.rma.wizard"].browse(wizard_id)
self.assertEqual(wizard.line_ids.quantity, 1)
wizard.create_and_open_rma()
# Now we open the wizard again and try to force the RMA qty wich should
# be 0 at this time
wizard_id = order.action_create_rma()["res_id"]
wizard = self.env["sale.order.rma.wizard"].browse(wizard_id)
self.assertEqual(wizard.line_ids.quantity, 0)
wizard.line_ids.quantity = 1
with self.assertRaises(ValidationError):
wizard.create_and_open_rma()

View File

@@ -1,6 +1,7 @@
# Copyright 2020 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class SaleOrderRmaWizard(models.TransientModel):
@@ -50,6 +51,12 @@ class SaleOrderRmaWizard(models.TransientModel):
product_kit_component_lines = kit_component_lines.filtered(
lambda x: x.product_id == product and x.quantity
)
if not product_kit_component_lines:
raise ValidationError(_(
"The kit corresponding to the product %s can't be "
"put in the RMA. Either all or some of the components "
"where already put in another RMA"
) % line.product_id.name)
qty_to_return = (
product_kit_component_lines[0].per_kit_quantity
* line.quantity