mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[FIX] rma_sale: product in multiple lines
If there are several stock moves with the same product in the picking we won't be able to make the RMA
This commit is contained in:
@@ -36,6 +36,7 @@ class SaleOrder(models.Model):
|
||||
{
|
||||
"product_id": data["product"].id,
|
||||
"quantity": data["quantity"],
|
||||
"sale_line_id": data["sale_line_id"].id,
|
||||
"uom_id": data["uom"].id,
|
||||
"picking_id": data["picking"] and data["picking"].id,
|
||||
},
|
||||
@@ -83,7 +84,7 @@ class SaleOrderLine(models.Model):
|
||||
self.ensure_one()
|
||||
return self.move_ids.filtered(
|
||||
lambda r: (
|
||||
self.product_id == r.product_id
|
||||
self == r.sale_line_id
|
||||
and r.state == "done"
|
||||
and not r.scrapped
|
||||
and r.location_dest_id.usage == "customer"
|
||||
@@ -114,6 +115,7 @@ class SaleOrderLine(models.Model):
|
||||
"quantity": qty,
|
||||
"uom": move.product_uom,
|
||||
"picking": move.picking_id,
|
||||
"sale_line_id": self,
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -123,6 +125,7 @@ class SaleOrderLine(models.Model):
|
||||
"quantity": self.qty_delivered,
|
||||
"uom": self.product_uom,
|
||||
"picking": False,
|
||||
"sale_line_id": self,
|
||||
}
|
||||
)
|
||||
return data
|
||||
|
||||
@@ -100,6 +100,12 @@
|
||||
t-attf-name="#{data_index}-product_id"
|
||||
t-att-value="data['product'].id"
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
t-if="data.get('sale_line_id')"
|
||||
t-attf-name="#{data_index}-sale_line_id"
|
||||
t-att-value="data['sale_line_id'].id"
|
||||
/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div id="delivery-rma-qty">
|
||||
|
||||
@@ -111,6 +111,7 @@ class SaleOrderLineRmaWizard(models.TransientModel):
|
||||
operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation", string="Requested operation",
|
||||
)
|
||||
sale_line_id = fields.Many2one(comodel_name="sale.order.line",)
|
||||
description = fields.Text()
|
||||
|
||||
@api.onchange("product_id")
|
||||
@@ -124,7 +125,8 @@ class SaleOrderLineRmaWizard(models.TransientModel):
|
||||
if record.picking_id:
|
||||
record.move_id = record.picking_id.move_lines.filtered(
|
||||
lambda r: (
|
||||
r.sale_line_id.product_id == record.product_id
|
||||
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
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user