diff --git a/rma_sale/models/rma.py b/rma_sale/models/rma.py
index 4ffc5e5f..7446ca2c 100644
--- a/rma_sale/models/rma.py
+++ b/rma_sale/models/rma.py
@@ -53,7 +53,7 @@ class Rma(models.Model):
if rec.order_id:
order_move = rec.order_id.order_line.mapped("move_ids")
rec.allowed_move_ids = order_move.filtered(
- lambda r: r.picking_id == self.picking_id
+ lambda r: r.picking_id == self.picking_id and r.state == "done"
).ids
else:
rec.allowed_move_ids = self.picking_id.move_lines.ids
diff --git a/rma_sale/wizard/sale_order_rma_wizard.py b/rma_sale/wizard/sale_order_rma_wizard.py
index 04c30cdf..cc0d3ea1 100644
--- a/rma_sale/wizard/sale_order_rma_wizard.py
+++ b/rma_sale/wizard/sale_order_rma_wizard.py
@@ -167,6 +167,7 @@ class SaleOrderLineRmaWizard(models.TransientModel):
r.sale_line_id == record.sale_line_id
and r.sale_line_id.product_id == record.product_id
and r.sale_line_id.order_id == record.order_id
+ and r.state == "done"
)
)
record.move_id = move_id
@@ -183,7 +184,9 @@ class SaleOrderLineRmaWizard(models.TransientModel):
line = record.order_id.order_line.filtered(
lambda r: r.product_id == record.product_id
)
- record.allowed_picking_ids = line.mapped("move_ids.picking_id")
+ record.allowed_picking_ids = line.mapped("move_ids.picking_id").filtered(
+ lambda x: x.state == "done"
+ )
def _prepare_rma_values(self):
self.ensure_one()
diff --git a/rma_sale/wizard/sale_order_rma_wizard_views.xml b/rma_sale/wizard/sale_order_rma_wizard_views.xml
index 254c8b2b..505020b0 100644
--- a/rma_sale/wizard/sale_order_rma_wizard_views.xml
+++ b/rma_sale/wizard/sale_order_rma_wizard_views.xml
@@ -25,7 +25,11 @@
options="{'no_create': True}"
/>
-
+