[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
parent 2378127a7b
commit 648d95aaca
7 changed files with 39 additions and 35 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
: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 <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 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.
@@ -114,6 +114,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|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.

View File

@@ -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",

View File

@@ -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

View File

@@ -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"

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Return Merchandise Authorization Management - Link with MRP Kits</title>
<style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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.
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>
@@ -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>.
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
<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>
</div>
<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>
<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>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>
</div>
</div>

View File

@@ -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)

View File

@@ -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"""