diff --git a/README.md b/README.md
index 2a07a7f32..b82e832f2 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Available addons
addon | version | maintainers | summary
--- | --- | --- | ---
[product_warranty](product_warranty/) | 18.0.1.0.0 |
| Product Warranty
-[rma](rma/) | 18.0.2.4.2 |
| Return Merchandise Authorization (RMA)
+[rma](rma/) | 18.0.2.4.4 |
| Return Merchandise Authorization (RMA)
[rma_batch](rma_batch/) | 18.0.1.0.0 | | Group RMAs into batches for collective management
[rma_delivery](rma_delivery/) | 18.0.1.4.1 |
| Allow to choose a default delivery carrier for returns
[rma_lot](rma_lot/) | 18.0.1.3.0 | | Manage lot in RMA
diff --git a/rma/README.rst b/rma/README.rst
index 8d229a64f..e0d63f998 100644
--- a/rma/README.rst
+++ b/rma/README.rst
@@ -11,7 +11,7 @@ Return Merchandise Authorization Management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:6db2a3295eba4c42d659410a81781a5e7bce6c5e9dc4fe1bd318e1d276027d64
+ !! source digest: sha256:98f1ab47d6cb82658fe2c8ac1b539bd710f5119792a6ea57d694caff0d550226
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
diff --git a/rma/__manifest__.py b/rma/__manifest__.py
index 5601b38e9..78083c961 100644
--- a/rma/__manifest__.py
+++ b/rma/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Return Merchandise Authorization Management",
"summary": "Return Merchandise Authorization (RMA)",
- "version": "18.0.2.4.2",
+ "version": "18.0.2.4.4",
"development_status": "Production/Stable",
"category": "RMA",
"website": "https://github.com/OCA/rma",
diff --git a/rma/models/rma.py b/rma/models/rma.py
index 2bf8df7da..d812846d7 100644
--- a/rma/models/rma.py
+++ b/rma/models/rma.py
@@ -477,12 +477,7 @@ def _compute_can_be_replaced(self):
r.can_be_replaced = (
r.operation_id.action_create_delivery
in ("manual_after_receipt", "automatic_after_receipt")
- and r.state
- in [
- "received",
- "waiting_replacement",
- "replaced",
- ]
+ and r.state == "received"
) or (
r.operation_id.action_create_delivery
in ("manual_on_confirm", "automatic_on_confirm")
@@ -995,6 +990,7 @@ def action_finish(self):
def action_cancel(self):
"""Invoked when 'Cancel' button in rma form view is clicked."""
self.reception_move_id._action_cancel()
+ self.delivery_move_ids._action_cancel()
self.write({"state": "cancelled"})
def action_draft(self):
diff --git a/rma/static/description/index.html b/rma/static/description/index.html
index ebacdf0b0..a1e9fd2a5 100644
--- a/rma/static/description/index.html
+++ b/rma/static/description/index.html
@@ -372,7 +372,7 @@
Return Merchandise Authorization Management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:6db2a3295eba4c42d659410a81781a5e7bce6c5e9dc4fe1bd318e1d276027d64
+!! source digest: sha256:98f1ab47d6cb82658fe2c8ac1b539bd710f5119792a6ea57d694caff0d550226
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

This module allows you to manage Return Merchandise Authorization
diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py
index f368fd352..4351796bd 100644
--- a/rma/tests/test_rma.py
+++ b/rma/tests/test_rma.py
@@ -379,7 +379,7 @@ def test_confirm_and_receive_and_return(self):
self.assertEqual(res["res_id"], new_rma.id)
@mute_logger("odoo.models.unlink")
- def test_cancel(self):
+ def test_cancel_01(self):
# cancel a draft RMA
rma = self._create_rma(self.partner, self.product)
rma.action_cancel()
@@ -394,6 +394,27 @@ def test_cancel(self):
with self.assertRaises(UserError):
rma.action_cancel()
+ @mute_logger("odoo.models.unlink")
+ def test_cancel_02(self):
+ self.operation.action_create_delivery = "manual_on_confirm"
+ rma = self._create_rma(self.partner, self.product)
+ rma.action_confirm()
+ self.assertEqual(rma.state, "confirmed")
+ reception_picking = rma.reception_move_id.picking_id
+ self.assertEqual(reception_picking.state, "assigned")
+ res = rma.action_replace()
+ delivery_form = Form(self.env[res["res_model"]].with_context(**res["context"]))
+ delivery_form.product_id = self.product
+ delivery_wizard = delivery_form.save()
+ delivery_wizard.action_deliver()
+ self.assertEqual(rma.state, "waiting_replacement")
+ delivery_picking = rma.delivery_move_ids.picking_id
+ self.assertEqual(delivery_picking.state, "confirmed")
+ rma.action_cancel()
+ self.assertEqual(rma.state, "cancelled")
+ self.assertEqual(reception_picking.state, "cancel")
+ self.assertEqual(delivery_picking.state, "cancel")
+
def test_lock_unlock(self):
# A RMA is only locked from 'received' state
rma_1 = self._create_rma(self.partner, self.product, 10, self.rma_loc)
@@ -558,11 +579,15 @@ def test_replace(self):
self.assertEqual(rma.state, "waiting_replacement")
self.assertFalse(rma.can_be_refunded)
self.assertFalse(rma.can_be_returned)
- self.assertTrue(rma.can_be_replaced)
+ self.assertFalse(rma.can_be_replaced)
self.assertEqual(rma.delivered_qty, 2)
self.assertEqual(rma.remaining_qty, 8)
first_move = rma.delivery_move_ids
picking = first_move.picking_id
+ picking.action_cancel()
+ self.assertEqual(picking.state, "cancel")
+ self.assertEqual(rma.state, "received")
+ self.assertTrue(rma.can_be_replaced)
# Replace again with another product with the remaining quantity
product_3 = self.product_product.create(
{"name": "Product 3 test", "type": "consu", "is_storable": True}
@@ -578,19 +603,17 @@ def test_replace(self):
delivery_wizard.action_deliver()
second_move = rma.delivery_move_ids - first_move
self.assertEqual(len(rma.delivery_move_ids), 2)
- self.assertEqual(rma.delivery_move_ids.mapped("picking_id"), picking)
+ new_picking = second_move.picking_id
self.assertEqual(first_move.product_id, product_2)
self.assertEqual(first_move.product_uom_qty, 2)
self.assertEqual(second_move.product_id, product_3)
- self.assertEqual(second_move.product_uom_qty, 8)
- self.assertTrue(picking.state, "waiting")
+ self.assertEqual(second_move.product_uom_qty, 10)
+ self.assertTrue(new_picking.state, "waiting")
self.assertEqual(rma.delivered_qty, 10)
self.assertEqual(rma.remaining_qty, 0)
- # remaining_qty is 0 but rma is not set to 'replaced' until
- first_move.quantity = 2
- second_move.quantity = 8
- picking.button_validate()
- self.assertEqual(picking.state, "done")
+ second_move.quantity = 10
+ new_picking.button_validate()
+ self.assertEqual(new_picking.state, "done")
self.assertEqual(rma.delivered_qty, 10)
self.assertEqual(rma.remaining_qty, 0)
# The RMA is now in 'replaced' state
@@ -598,8 +621,8 @@ def test_replace(self):
self.assertFalse(rma.can_be_refunded)
self.assertFalse(rma.can_be_returned)
# Despite being in 'replaced' state,
- # RMAs can still perform replacements.
- self.assertTrue(rma.can_be_replaced)
+ # RMAs can't still perform replacements.
+ self.assertFalse(rma.can_be_replaced)
def test_return_to_customer(self):
# Create, confirm and receive an RMA
diff --git a/rma/tests/test_rma_operation.py b/rma/tests/test_rma_operation.py
index b1281d27c..d9e72a234 100644
--- a/rma/tests/test_rma_operation.py
+++ b/rma/tests/test_rma_operation.py
@@ -133,7 +133,7 @@ def test_06(self):
self.assertEqual(rma.state, "waiting_replacement")
self.assertFalse(rma.can_be_returned)
self.assertFalse(rma.show_create_return)
- self.assertTrue(rma.can_be_replaced)
+ self.assertFalse(rma.can_be_replaced)
self.assertFalse(rma.show_create_replace)
def test_07(self):