mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[FIX] rma_sale: Allow to request a rma from portal order page only with portal user permission
This commit is contained in:
@@ -99,6 +99,7 @@ Contributors
|
|||||||
* Ernesto Tejeda
|
* Ernesto Tejeda
|
||||||
* Pedro M. Baeza
|
* Pedro M. Baeza
|
||||||
* David Vidal
|
* David Vidal
|
||||||
|
* Víctor Martínez
|
||||||
|
|
||||||
* Chafique Delli <chafique.delli@akretion.com>
|
* Chafique Delli <chafique.delli@akretion.com>
|
||||||
* Giovanni Serra - Ooops <giovanni@ooops404.com>
|
* Giovanni Serra - Ooops <giovanni@ooops404.com>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CustomerPortal(CustomerPortal):
|
|||||||
except (AccessError, MissingError):
|
except (AccessError, MissingError):
|
||||||
return request.redirect("/my")
|
return request.redirect("/my")
|
||||||
order_obj = request.env["sale.order"]
|
order_obj = request.env["sale.order"]
|
||||||
wizard_obj = request.env["sale.order.rma.wizard"]
|
wizard_obj = request.env["sale.order.rma.wizard"].sudo()
|
||||||
wizard_line_field_types = {
|
wizard_line_field_types = {
|
||||||
f: d["type"] for f, d in wizard_obj.line_ids.fields_get().items()
|
f: d["type"] for f, d in wizard_obj.line_ids.fields_get().items()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Ernesto Tejeda
|
* Ernesto Tejeda
|
||||||
* Pedro M. Baeza
|
* Pedro M. Baeza
|
||||||
* David Vidal
|
* David Vidal
|
||||||
|
* Víctor Martínez
|
||||||
|
|
||||||
* Chafique Delli <chafique.delli@akretion.com>
|
* Chafique Delli <chafique.delli@akretion.com>
|
||||||
* Giovanni Serra - Ooops <giovanni@ooops404.com>
|
* Giovanni Serra - Ooops <giovanni@ooops404.com>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<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 Sales</title>
|
<title>Return Merchandise Authorization Management - Link with Sales</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
@@ -448,6 +448,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||||||
<li>Ernesto Tejeda</li>
|
<li>Ernesto Tejeda</li>
|
||||||
<li>Pedro M. Baeza</li>
|
<li>Pedro M. Baeza</li>
|
||||||
<li>David Vidal</li>
|
<li>David Vidal</li>
|
||||||
|
<li>Víctor Martínez</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>Chafique Delli <<a class="reference external" href="mailto:chafique.delli@akretion.com">chafique.delli@akretion.com</a>></li>
|
<li>Chafique Delli <<a class="reference external" href="mailto:chafique.delli@akretion.com">chafique.delli@akretion.com</a>></li>
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
# 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.tests import Form, SavepointCase
|
from odoo.tests import Form, SavepointCase
|
||||||
|
from odoo.tests.common import users
|
||||||
|
|
||||||
|
|
||||||
class TestRmaSale(SavepointCase):
|
class TestRmaSale(SavepointCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestRmaSale, cls).setUpClass()
|
super().setUpClass()
|
||||||
cls.res_partner = cls.env["res.partner"]
|
cls.res_partner = cls.env["res.partner"]
|
||||||
cls.product_product = cls.env["product.product"]
|
cls.product_product = cls.env["product.product"]
|
||||||
cls.sale_order = cls.env["sale.order"]
|
cls.sale_order = cls.env["sale.order"]
|
||||||
@@ -18,7 +20,10 @@ class TestRmaSale(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"})
|
cls.partner = cls.res_partner.create(
|
||||||
|
{"name": "Partner test", "email": "partner@rma"}
|
||||||
|
)
|
||||||
|
cls._partner_portal_wizard(cls, cls.partner)
|
||||||
order_form = Form(cls.sale_order)
|
order_form = Form(cls.sale_order)
|
||||||
order_form.partner_id = cls.partner
|
order_form.partner_id = cls.partner
|
||||||
with order_form.order_line.new() as line_form:
|
with order_form.order_line.new() as line_form:
|
||||||
@@ -35,6 +40,15 @@ class TestRmaSale(SavepointCase):
|
|||||||
cls.order_out_picking.move_lines.quantity_done = 5
|
cls.order_out_picking.move_lines.quantity_done = 5
|
||||||
cls.order_out_picking.button_validate()
|
cls.order_out_picking.button_validate()
|
||||||
|
|
||||||
|
def _partner_portal_wizard(self, partner):
|
||||||
|
wizard_all = (
|
||||||
|
self.env["portal.wizard"]
|
||||||
|
.with_context({"active_ids": [partner.id]})
|
||||||
|
.create({})
|
||||||
|
)
|
||||||
|
wizard_all.user_ids.in_portal = True
|
||||||
|
wizard_all.action_apply()
|
||||||
|
|
||||||
def _rma_sale_wizard(self, order):
|
def _rma_sale_wizard(self, order):
|
||||||
wizard_id = order.action_create_rma()["res_id"]
|
wizard_id = order.action_create_rma()["res_id"]
|
||||||
return self.env["sale.order.rma.wizard"].browse(wizard_id)
|
return self.env["sale.order.rma.wizard"].browse(wizard_id)
|
||||||
@@ -83,6 +97,37 @@ class TestRmaSale(SavepointCase):
|
|||||||
rma.action_refund()
|
rma.action_refund()
|
||||||
self.assertEqual(rma.refund_id.user_id, user)
|
self.assertEqual(rma.refund_id.user_id, user)
|
||||||
|
|
||||||
|
@users("partner@rma")
|
||||||
|
def test_create_rma_from_so_portal_user(self):
|
||||||
|
order = self.sale_order
|
||||||
|
wizard_obj = (
|
||||||
|
self.env["sale.order.rma.wizard"].sudo().with_context(active_id=order)
|
||||||
|
)
|
||||||
|
operation = self.env["rma.operation"].sudo().search([], limit=1)
|
||||||
|
line_vals = [
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"product_id": order.order_line.product_id.id,
|
||||||
|
"sale_line_id": order.order_line.id,
|
||||||
|
"quantity": order.order_line.product_uom_qty,
|
||||||
|
"uom_id": order.order_line.product_uom.id,
|
||||||
|
"picking_id": order.picking_ids[0].id,
|
||||||
|
"operation_id": operation.id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
]
|
||||||
|
wizard = wizard_obj.create(
|
||||||
|
{
|
||||||
|
"line_ids": line_vals,
|
||||||
|
"location_id": order.warehouse_id.rma_loc_id.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
rma = wizard.sudo().create_rma(from_portal=True)
|
||||||
|
self.assertEqual(rma.order_id, order)
|
||||||
|
self.assertIn(order.partner_id, rma.message_partner_ids)
|
||||||
|
|
||||||
def test_create_recurrent_rma(self):
|
def test_create_recurrent_rma(self):
|
||||||
"""An RMA of a product that had an RMA in the past should be possible"""
|
"""An RMA of a product that had an RMA in the past should be possible"""
|
||||||
wizard = self._rma_sale_wizard(self.sale_order)
|
wizard = self._rma_sale_wizard(self.sale_order)
|
||||||
|
|||||||
Reference in New Issue
Block a user