diff --git a/rma_sale_mrp/README.rst b/rma_sale_mrp/README.rst index 0ee1b502..a06e04ec 100644 --- a/rma_sale_mrp/README.rst +++ b/rma_sale_mrp/README.rst @@ -14,13 +14,13 @@ Return Merchandise Authorization Management - Link with MRP Kits :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_sale_mrp + :target: https://github.com/OCA/rma/tree/15.0/rma_sale_mrp :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_sale_mrp + :target: https://translation.odoo-community.org/projects/rma-15-0/rma-15-0-rma_sale_mrp :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/145/14.0 + :target: https://runbot.odoo-community.org/runbot/145/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -74,7 +74,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -114,6 +114,6 @@ Current `maintainer `__: |maintainer-chienandalu| -This module is part of the `OCA/rma `_ project on GitHub. +This module is part of the `OCA/rma `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/rma_sale_mrp/__manifest__.py b/rma_sale_mrp/__manifest__.py index 9d22d5ff..bab7f708 100644 --- a/rma_sale_mrp/__manifest__.py +++ b/rma_sale_mrp/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management - Link with MRP Kits", "summary": "Allow doing RMAs from MRP kits", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "development_status": "Beta", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma_sale_mrp/i18n/es.po b/rma_sale_mrp/i18n/es.po index dcd707d6..bb4f5bc8 100644 --- a/rma_sale_mrp/i18n/es.po +++ b/rma_sale_mrp/i18n/es.po @@ -158,8 +158,8 @@ msgid "ID" msgstr "" #. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_account_invoice -msgid "Invoice" +#: model:ir.model,name:rma_sale_mrp.model_account_move +msgid "Journal Entry" msgstr "" #. module: rma_sale_mrp @@ -256,11 +256,6 @@ msgstr "Registro de RMA del kit" msgid "Sale Line" msgstr "Línea de venta" -#. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_sale_order -msgid "Sale Order" -msgstr "Pedido de venta" - #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard msgid "Sale Order Line Rma Wizard" @@ -271,13 +266,18 @@ msgstr "Asistente de RMA" msgid "Sale Order Rma Wizard" msgstr "Asistente de Orden de Venta - RMA" +#. module: rma_sale_mrp +#: model:ir.model,name:rma_sale_mrp.model_sale_order +msgid "Sales Order" +msgstr "" + #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line 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 +#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:0 #, python-format msgid "" "The kit corresponding to the product %s can't be put in the RMA. Either all " @@ -317,7 +317,10 @@ msgid "Wizard" msgstr "Asistente" #. module: rma_sale_mrp -#: code:addons/rma_sale_mrp/models/rma.py:49 +#: code:addons/rma_sale_mrp/models/rma.py:0 #, python-format msgid "You can't refund a kit in wich some RMAs aren't received" msgstr "No puedes reembolsar un kit cuyos RMAs no están en estado `recibido`" + +#~ msgid "Sale Order" +#~ msgstr "Pedido de venta" diff --git a/rma_sale_mrp/i18n/pt.po b/rma_sale_mrp/i18n/pt.po index 0b0a1c92..2eb4f9e7 100644 --- a/rma_sale_mrp/i18n/pt.po +++ b/rma_sale_mrp/i18n/pt.po @@ -152,9 +152,9 @@ msgid "ID" msgstr "ID" #. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_account_invoice -msgid "Invoice" -msgstr "Fatura" +#: model:ir.model,name:rma_sale_mrp.model_account_move +msgid "Journal Entry" +msgstr "" #. module: rma_sale_mrp #: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_my_rmas @@ -250,11 +250,6 @@ msgstr "" msgid "Sale Line" msgstr "Linha de Venda" -#. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_sale_order -msgid "Sale Order" -msgstr "Encomenda de Venda" - #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard msgid "Sale Order Line Rma Wizard" @@ -265,13 +260,18 @@ msgstr "Assistente da Linha de RMA da Encomenda de Venda" msgid "Sale Order Rma Wizard" msgstr "Assistente da RMA da Encomenda de Venda" +#. module: rma_sale_mrp +#: model:ir.model,name:rma_sale_mrp.model_sale_order +msgid "Sales Order" +msgstr "" + #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line 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 +#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:0 #, python-format msgid "" "The kit corresponding to the product %s can't be put in the RMA. Either all " @@ -307,7 +307,13 @@ msgid "Wizard" msgstr "Assistente" #. module: rma_sale_mrp -#: code:addons/rma_sale_mrp/models/rma.py:49 +#: code:addons/rma_sale_mrp/models/rma.py:0 #, python-format msgid "You can't refund a kit in wich some RMAs aren't received" msgstr "" + +#~ msgid "Invoice" +#~ msgstr "Fatura" + +#~ msgid "Sale Order" +#~ msgstr "Encomenda de Venda" diff --git a/rma_sale_mrp/i18n/pt_BR.po b/rma_sale_mrp/i18n/pt_BR.po index 743a6e0b..8f0872f1 100644 --- a/rma_sale_mrp/i18n/pt_BR.po +++ b/rma_sale_mrp/i18n/pt_BR.po @@ -157,9 +157,9 @@ msgid "ID" msgstr "ID" #. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_account_invoice -msgid "Invoice" -msgstr "Fatura" +#: model:ir.model,name:rma_sale_mrp.model_account_move +msgid "Journal Entry" +msgstr "" #. module: rma_sale_mrp #: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_my_rmas @@ -255,11 +255,6 @@ msgstr "Registro de Kit RMA" msgid "Sale Line" msgstr "Linha de Venda" -#. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_sale_order -msgid "Sale Order" -msgstr "Pedido de Venda" - #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard msgid "Sale Order Line Rma Wizard" @@ -270,13 +265,18 @@ msgstr "Assistente da Linha do Pedido de Venda RMA" msgid "Sale Order Rma Wizard" msgstr "Assistente do Pedido de Venda RMA" +#. module: rma_sale_mrp +#: model:ir.model,name:rma_sale_mrp.model_sale_order +msgid "Sales Order" +msgstr "" + #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line 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 +#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:0 #, python-format msgid "" "The kit corresponding to the product %s can't be put in the RMA. Either all " @@ -316,7 +316,13 @@ msgid "Wizard" msgstr "Assistente" #. module: rma_sale_mrp -#: code:addons/rma_sale_mrp/models/rma.py:49 +#: code:addons/rma_sale_mrp/models/rma.py:0 #, python-format msgid "You can't refund a kit in wich some RMAs aren't received" msgstr "Você não pode reembolsar um kit em que alguns RMAs não foram recebidos" + +#~ msgid "Invoice" +#~ msgstr "Fatura" + +#~ msgid "Sale Order" +#~ msgstr "Pedido de Venda" diff --git a/rma_sale_mrp/i18n/rma_sale_mrp.pot b/rma_sale_mrp/i18n/rma_sale_mrp.pot index 7a29f000..b358e8aa 100644 --- a/rma_sale_mrp/i18n/rma_sale_mrp.pot +++ b/rma_sale_mrp/i18n/rma_sale_mrp.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -133,24 +133,12 @@ msgid "Description" msgstr "" #. module: rma_sale_mrp -#: model:ir.model.fields,field_description:rma_sale_mrp.field_account_move__display_name -#: model:ir.model.fields,field_description:rma_sale_mrp.field_rma__display_name -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order__display_name -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line__display_name -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard__display_name #: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component__display_name -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_rma_wizard__display_name msgid "Display Name" msgstr "" #. module: rma_sale_mrp -#: model:ir.model.fields,field_description:rma_sale_mrp.field_account_move__id -#: model:ir.model.fields,field_description:rma_sale_mrp.field_rma__id -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order__id -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line__id -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard__id #: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component__id -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_rma_wizard__id msgid "ID" msgstr "" @@ -176,13 +164,7 @@ msgid "Kit quantity" msgstr "" #. module: rma_sale_mrp -#: model:ir.model.fields,field_description:rma_sale_mrp.field_account_move____last_update -#: model:ir.model.fields,field_description:rma_sale_mrp.field_rma____last_update -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order____last_update -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line____last_update -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard____last_update #: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_line_rma_wizard_component____last_update -#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_rma_wizard____last_update msgid "Last Modified on" msgstr "" diff --git a/rma_sale_mrp/models/rma.py b/rma_sale_mrp/models/rma.py index 870c3fbb..741af052 100644 --- a/rma_sale_mrp/models/rma.py +++ b/rma_sale_mrp/models/rma.py @@ -48,7 +48,7 @@ class Rma(models.Model): _("You can't refund a kit in wich some RMAs aren't received") ) self |= rmas_by_register[0] - super().action_refund() + res = super().action_refund() # We can just link the line to an RMA but we can link several RMAs # to one invoice line. for rma_kit_register in set(phantom_rmas.mapped("rma_kit_register")): @@ -64,3 +64,4 @@ class Rma(models.Model): "state": "refunded", } ) + return res diff --git a/rma_sale_mrp/models/sale_order.py b/rma_sale_mrp/models/sale_order.py index 418ac096..5a19459c 100644 --- a/rma_sale_mrp/models/sale_order.py +++ b/rma_sale_mrp/models/sale_order.py @@ -124,9 +124,9 @@ class SaleOrderLine(models.Model): self.env["mrp.bom"] .sudo() ._bom_find( - product=self.product_id, + products=self.product_id, company_id=self.company_id.id, bom_type="phantom", ) ) - return bom and bom.type == "phantom" + return bom and bom.get(self.product_id).type == "phantom" diff --git a/rma_sale_mrp/static/description/index.html b/rma_sale_mrp/static/description/index.html index f49f3644..853c48aa 100644 --- a/rma_sale_mrp/static/description/index.html +++ b/rma_sale_mrp/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/rma Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/rma Translate me on Weblate Try me on Runbot

This module enables RMAs for kits, wich isn’t compatible with the base modules. In the backend side, we can return separate component while in the frontend side, customers can return the whole kit and the proper RMAs will be generated.

@@ -423,7 +423,7 @@ version to use the same rules so they fail for the same reasons.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -452,7 +452,7 @@ mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

chienandalu

-

This module is part of the OCA/rma project on GitHub.

+

This module is part of the OCA/rma project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/rma_sale_mrp/tests/test_rma_sale_mrp.py b/rma_sale_mrp/tests/test_rma_sale_mrp.py index 8c34cd26..f60c028e 100644 --- a/rma_sale_mrp/tests/test_rma_sale_mrp.py +++ b/rma_sale_mrp/tests/test_rma_sale_mrp.py @@ -1,25 +1,21 @@ # Copyright 2020 Tecnativa - David Vidal +# Copyright 2022 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.exceptions import UserError, ValidationError -from odoo.tests import Form, SavepointCase +from odoo.tests import Form + +from odoo.addons.rma_sale.tests.test_rma_sale import TestRmaSaleBase -class TestRmaSaleMrp(SavepointCase): +class TestRmaSaleMrp(TestRmaSaleBase): @classmethod def setUpClass(cls): super().setUpClass() - cls.res_partner = cls.env["res.partner"] - cls.product_product = cls.env["product.product"] - cls.sale_order = cls.env["sale.order"] cls.product_kit = cls.product_product.create( {"name": "Product test 1", "type": "consu"} ) - cls.product_kit_comp_1 = cls.product_product.create( - {"name": "Product Component 1", "type": "product"} - ) - cls.product_kit_comp_2 = cls.product_product.create( - {"name": "Product Component 2", "type": "product"} - ) + cls.product_kit_comp_1 = cls.product_1 + cls.product_kit_comp_2 = cls.product_2 cls.bom = cls.env["mrp.bom"].create( { "product_id": cls.product_kit.id, @@ -42,13 +38,8 @@ class TestRmaSaleMrp(SavepointCase): cls.product_2 = cls.product_product.create( {"name": "Product test 2", "type": "product"} ) - cls.partner = cls.res_partner.create({"name": "Partner test"}) - order_form = Form(cls.sale_order) - order_form.partner_id = cls.partner - with order_form.order_line.new() as line_form: - line_form.product_id = cls.product_kit - line_form.product_uom_qty = 5 - cls.sale_order = order_form.save() + + cls.sale_order = cls._create_sale_order(cls, [[cls.product_kit, 5]]) cls.sale_order.action_confirm() # Maybe other modules create additional lines in the create # method in sale.order model, so let's find the correct line. @@ -62,7 +53,7 @@ class TestRmaSaleMrp(SavepointCase): line.quantity_done = line.product_uom_qty - 7 wiz_act = cls.order_out_picking.button_validate() wiz = Form( - cls.env[wiz_act["res_model"]].with_context(wiz_act["context"]) + cls.env[wiz_act["res_model"]].with_context(**wiz_act["context"]) ).save() wiz.process() cls.backorder = cls.sale_order.picking_ids - cls.order_out_picking @@ -73,8 +64,7 @@ class TestRmaSaleMrp(SavepointCase): def test_create_rma_from_so(self): order = self.sale_order out_pickings = self.order_out_picking + self.backorder - wizard_id = order.action_create_rma()["res_id"] - wizard = self.env["sale.order.rma.wizard"].browse(wizard_id) + wizard = self._rma_sale_wizard(order) wizard.line_ids.quantity = 4 res = wizard.create_and_open_rma() rmas = self.env["rma"].search(res["domain"]) @@ -149,3 +139,15 @@ class TestRmaSaleMrp(SavepointCase): wizard.line_ids.quantity = 1 with self.assertRaises(ValidationError): wizard.create_and_open_rma() + + def test_report_rma(self): + wizard = self._rma_sale_wizard(self.sale_order) + wizard.line_ids.quantity = 4 + res = wizard.create_and_open_rma() + rmas = self.env["rma"].search(res["domain"]) + for rma in rmas: + res = self.report_model._get_report_from_name( + "rma.report_rma" + )._render_qweb_text(rma.ids, False) + self.assertRegex(str(res[0]), self.product_kit_comp_1.name) + self.assertRegex(str(res[0]), self.product_kit_comp_2.name) diff --git a/rma_sale_mrp/wizard/sale_order_rma_wizard.py b/rma_sale_mrp/wizard/sale_order_rma_wizard.py index 321907ac..1f376abe 100644 --- a/rma_sale_mrp/wizard/sale_order_rma_wizard.py +++ b/rma_sale_mrp/wizard/sale_order_rma_wizard.py @@ -106,7 +106,7 @@ class SaleOrderLineRmaWizard(models.TransientModel): lambda x: not x.phantom_bom_product and not x.sale_line_id._rma_is_kit_product() ) - super(SaleOrderLineRmaWizard, not_kit)._compute_move_id() + res = super(SaleOrderLineRmaWizard, not_kit)._compute_move_id() for line in self.filtered(lambda x: x.phantom_bom_product and x.picking_id): line.move_id = line.picking_id.move_lines.filtered( lambda ml: ( @@ -116,6 +116,7 @@ class SaleOrderLineRmaWizard(models.TransientModel): and ml.sale_line_id.order_id == line.order_id ) ) + return res def _prepare_rma_values(self): """It will be used as a reference for the components"""