[MIG] rma_sale_mrp: Migration to 15.0

TT37303
This commit is contained in:
Víctor Martínez
2022-10-10 15:10:33 +02:00
committed by Pedro M. Baeza
parent 5b67cc30f5
commit 990e401afb
11 changed files with 83 additions and 82 deletions

View File

@@ -14,13 +14,13 @@ Return Merchandise Authorization Management - Link with MRP Kits
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github .. |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 :alt: OCA/rma
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -74,7 +74,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_. 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. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_sale_mrp%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_sale_mrp%0Aversion:%2015.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. Do not contact contributors directly about support or help with technical issues.
@@ -114,6 +114,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-chienandalu| |maintainer-chienandalu|
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/14.0/rma_sale_mrp>`_ project on GitHub. This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/15.0/rma_sale_mrp>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

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

View File

@@ -158,8 +158,8 @@ msgid "ID"
msgstr "" msgstr ""
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_account_invoice #: model:ir.model,name:rma_sale_mrp.model_account_move
msgid "Invoice" msgid "Journal Entry"
msgstr "" msgstr ""
#. module: rma_sale_mrp #. module: rma_sale_mrp
@@ -256,11 +256,6 @@ msgstr "Registro de RMA del kit"
msgid "Sale Line" msgid "Sale Line"
msgstr "Línea de venta" 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 #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard
msgid "Sale Order Line Rma Wizard" msgid "Sale Order Line Rma Wizard"
@@ -271,13 +266,18 @@ msgstr "Asistente de RMA"
msgid "Sale Order Rma Wizard" msgid "Sale Order Rma Wizard"
msgstr "Asistente de Orden de Venta - RMA" 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 #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_sale_order_line #: model:ir.model,name:rma_sale_mrp.model_sale_order_line
msgid "Sales Order Line" msgid "Sales Order Line"
msgstr "Línea de pedido de venta" msgstr "Línea de pedido de venta"
#. module: rma_sale_mrp #. 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 #, python-format
msgid "" msgid ""
"The kit corresponding to the product %s can't be put in the RMA. Either all " "The kit corresponding to the product %s can't be put in the RMA. Either all "
@@ -317,7 +317,10 @@ msgid "Wizard"
msgstr "Asistente" msgstr "Asistente"
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/models/rma.py:49 #: code:addons/rma_sale_mrp/models/rma.py:0
#, python-format #, python-format
msgid "You can't refund a kit in wich some RMAs aren't received" 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`" msgstr "No puedes reembolsar un kit cuyos RMAs no están en estado `recibido`"
#~ msgid "Sale Order"
#~ msgstr "Pedido de venta"

View File

@@ -152,9 +152,9 @@ msgid "ID"
msgstr "ID" msgstr "ID"
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_account_invoice #: model:ir.model,name:rma_sale_mrp.model_account_move
msgid "Invoice" msgid "Journal Entry"
msgstr "Fatura" msgstr ""
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_my_rmas #: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_my_rmas
@@ -250,11 +250,6 @@ msgstr ""
msgid "Sale Line" msgid "Sale Line"
msgstr "Linha de Venda" 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 #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard
msgid "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" msgid "Sale Order Rma Wizard"
msgstr "Assistente da RMA da Encomenda de Venda" 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 #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_sale_order_line #: model:ir.model,name:rma_sale_mrp.model_sale_order_line
msgid "Sales Order Line" msgid "Sales Order Line"
msgstr "Linha de Encomenda de Venda" msgstr "Linha de Encomenda de Venda"
#. module: rma_sale_mrp #. 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 #, python-format
msgid "" msgid ""
"The kit corresponding to the product %s can't be put in the RMA. Either all " "The kit corresponding to the product %s can't be put in the RMA. Either all "
@@ -307,7 +307,13 @@ msgid "Wizard"
msgstr "Assistente" msgstr "Assistente"
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/models/rma.py:49 #: code:addons/rma_sale_mrp/models/rma.py:0
#, python-format #, python-format
msgid "You can't refund a kit in wich some RMAs aren't received" msgid "You can't refund a kit in wich some RMAs aren't received"
msgstr "" msgstr ""
#~ msgid "Invoice"
#~ msgstr "Fatura"
#~ msgid "Sale Order"
#~ msgstr "Encomenda de Venda"

View File

@@ -157,9 +157,9 @@ msgid "ID"
msgstr "ID" msgstr "ID"
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_account_invoice #: model:ir.model,name:rma_sale_mrp.model_account_move
msgid "Invoice" msgid "Journal Entry"
msgstr "Fatura" msgstr ""
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_my_rmas #: 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" msgid "Sale Line"
msgstr "Linha de Venda" 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 #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard
msgid "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" msgid "Sale Order Rma Wizard"
msgstr "Assistente do Pedido de Venda RMA" 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 #. module: rma_sale_mrp
#: model:ir.model,name:rma_sale_mrp.model_sale_order_line #: model:ir.model,name:rma_sale_mrp.model_sale_order_line
msgid "Sales Order Line" msgid "Sales Order Line"
msgstr "Linha do Pedido de Venda" msgstr "Linha do Pedido de Venda"
#. module: rma_sale_mrp #. 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 #, python-format
msgid "" msgid ""
"The kit corresponding to the product %s can't be put in the RMA. Either all " "The kit corresponding to the product %s can't be put in the RMA. Either all "
@@ -316,7 +316,13 @@ msgid "Wizard"
msgstr "Assistente" msgstr "Assistente"
#. module: rma_sale_mrp #. module: rma_sale_mrp
#: code:addons/rma_sale_mrp/models/rma.py:49 #: code:addons/rma_sale_mrp/models/rma.py:0
#, python-format #, python-format
msgid "You can't refund a kit in wich some RMAs aren't received" 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" 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"

View File

@@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 14.0\n" "Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@@ -133,24 +133,12 @@ msgid "Description"
msgstr "" msgstr ""
#. module: rma_sale_mrp #. 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_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" msgid "Display Name"
msgstr "" msgstr ""
#. module: rma_sale_mrp #. 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_line_rma_wizard_component__id
#: model:ir.model.fields,field_description:rma_sale_mrp.field_sale_order_rma_wizard__id
msgid "ID" msgid "ID"
msgstr "" msgstr ""
@@ -176,13 +164,7 @@ msgid "Kit quantity"
msgstr "" msgstr ""
#. module: rma_sale_mrp #. 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_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" msgid "Last Modified on"
msgstr "" msgstr ""

View File

@@ -48,7 +48,7 @@ class Rma(models.Model):
_("You can't refund a kit in wich some RMAs aren't received") _("You can't refund a kit in wich some RMAs aren't received")
) )
self |= rmas_by_register[0] 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 # We can just link the line to an RMA but we can link several RMAs
# to one invoice line. # to one invoice line.
for rma_kit_register in set(phantom_rmas.mapped("rma_kit_register")): for rma_kit_register in set(phantom_rmas.mapped("rma_kit_register")):
@@ -64,3 +64,4 @@ class Rma(models.Model):
"state": "refunded", "state": "refunded",
} }
) )
return res

View File

@@ -124,9 +124,9 @@ class SaleOrderLine(models.Model):
self.env["mrp.bom"] self.env["mrp.bom"]
.sudo() .sudo()
._bom_find( ._bom_find(
product=self.product_id, products=self.product_id,
company_id=self.company_id.id, company_id=self.company_id.id,
bom_type="phantom", bom_type="phantom",
) )
) )
return bom and bom.type == "phantom" return bom and bom.get(self.product_id).type == "phantom"

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/rma/tree/14.0/rma_sale_mrp"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-14-0/rma-14-0-rma_sale_mrp"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/rma/tree/15.0/rma_sale_mrp"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-15-0/rma-15-0-rma_sale_mrp"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module enables RMAs for kits, wich isnt compatible with the base modules. <p>This module enables RMAs for kits, wich isnt compatible with the base modules.
In the backend side, we can return separate component while in the frontend 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.</p> side, customers can return the whole kit and the proper RMAs will be generated.</p>
@@ -423,7 +423,7 @@ version to use the same rules so they fail for the same reasons.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma_sale_mrp%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma_sale_mrp%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -452,7 +452,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/chienandalu"><img alt="chienandalu" src="https://github.com/chienandalu.png?size=40px" /></a></p> <p><a class="reference external" href="https://github.com/chienandalu"><img alt="chienandalu" src="https://github.com/chienandalu.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/14.0/rma_sale_mrp">OCA/rma</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/15.0/rma_sale_mrp">OCA/rma</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -1,25 +1,21 @@
# Copyright 2020 Tecnativa - David Vidal # Copyright 2020 Tecnativa - David Vidal
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.exceptions import UserError, ValidationError 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 @classmethod
def setUpClass(cls): def setUpClass(cls):
super().setUpClass() 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( cls.product_kit = cls.product_product.create(
{"name": "Product test 1", "type": "consu"} {"name": "Product test 1", "type": "consu"}
) )
cls.product_kit_comp_1 = cls.product_product.create( cls.product_kit_comp_1 = cls.product_1
{"name": "Product Component 1", "type": "product"} cls.product_kit_comp_2 = cls.product_2
)
cls.product_kit_comp_2 = cls.product_product.create(
{"name": "Product Component 2", "type": "product"}
)
cls.bom = cls.env["mrp.bom"].create( cls.bom = cls.env["mrp.bom"].create(
{ {
"product_id": cls.product_kit.id, "product_id": cls.product_kit.id,
@@ -42,13 +38,8 @@ class TestRmaSaleMrp(SavepointCase):
cls.product_2 = cls.product_product.create( cls.product_2 = cls.product_product.create(
{"name": "Product test 2", "type": "product"} {"name": "Product test 2", "type": "product"}
) )
cls.partner = cls.res_partner.create({"name": "Partner test"})
order_form = Form(cls.sale_order) cls.sale_order = cls._create_sale_order(cls, [[cls.product_kit, 5]])
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.action_confirm() cls.sale_order.action_confirm()
# Maybe other modules create additional lines in the create # Maybe other modules create additional lines in the create
# method in sale.order model, so let's find the correct line. # 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 line.quantity_done = line.product_uom_qty - 7
wiz_act = cls.order_out_picking.button_validate() wiz_act = cls.order_out_picking.button_validate()
wiz = Form( 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() ).save()
wiz.process() wiz.process()
cls.backorder = cls.sale_order.picking_ids - cls.order_out_picking 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): def test_create_rma_from_so(self):
order = self.sale_order order = self.sale_order
out_pickings = self.order_out_picking + self.backorder out_pickings = self.order_out_picking + self.backorder
wizard_id = order.action_create_rma()["res_id"] wizard = self._rma_sale_wizard(order)
wizard = self.env["sale.order.rma.wizard"].browse(wizard_id)
wizard.line_ids.quantity = 4 wizard.line_ids.quantity = 4
res = wizard.create_and_open_rma() res = wizard.create_and_open_rma()
rmas = self.env["rma"].search(res["domain"]) rmas = self.env["rma"].search(res["domain"])
@@ -149,3 +139,15 @@ class TestRmaSaleMrp(SavepointCase):
wizard.line_ids.quantity = 1 wizard.line_ids.quantity = 1
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
wizard.create_and_open_rma() 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)

View File

@@ -106,7 +106,7 @@ class SaleOrderLineRmaWizard(models.TransientModel):
lambda x: not x.phantom_bom_product lambda x: not x.phantom_bom_product
and not x.sale_line_id._rma_is_kit_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): for line in self.filtered(lambda x: x.phantom_bom_product and x.picking_id):
line.move_id = line.picking_id.move_lines.filtered( line.move_id = line.picking_id.move_lines.filtered(
lambda ml: ( lambda ml: (
@@ -116,6 +116,7 @@ class SaleOrderLineRmaWizard(models.TransientModel):
and ml.sale_line_id.order_id == line.order_id and ml.sale_line_id.order_id == line.order_id
) )
) )
return res
def _prepare_rma_values(self): def _prepare_rma_values(self):
"""It will be used as a reference for the components""" """It will be used as a reference for the components"""