mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] rma_filter_lot: show only the lots shipped to the particular customer in the RMA.
If nothing was shipped to that customer, fall back to showing all the lots available in the customer location.
This commit is contained in:
@@ -27,6 +27,7 @@ Contributors
|
||||
|
||||
* Mateu Griful <mateu.griful@forgeflow.com>
|
||||
* Lois Rilo <lois.rilo@forgeflow.com>
|
||||
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
|
||||
{
|
||||
"name": "RMA Filter Lot",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.1.1.0",
|
||||
"license": "LGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "Filter RMA lots",
|
||||
"author": "ForgeFlow",
|
||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["rma"],
|
||||
"data": [
|
||||
"views/rma_order_view.xml",
|
||||
],
|
||||
"data": ["views/rma_order_view.xml"],
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -16,7 +16,20 @@ class RmaOrderLine(models.Model):
|
||||
compute="_compute_domain_lot_ids",
|
||||
)
|
||||
|
||||
@api.depends("product_id")
|
||||
def _get_filter_lot_customer_domain(self):
|
||||
self.ensure_one()
|
||||
return [
|
||||
("location_dest_id.usage", "=", "customer"),
|
||||
("product_id", "=", self.product_id.id),
|
||||
("state", "=", "done"),
|
||||
(
|
||||
"move_id.partner_id",
|
||||
"child_of",
|
||||
self.partner_id.commercial_partner_id.ids,
|
||||
),
|
||||
]
|
||||
|
||||
@api.depends("product_id", "operation_id")
|
||||
def _compute_domain_lot_ids(self):
|
||||
for rec in self:
|
||||
lots = rec.env["stock.production.lot"].search(
|
||||
@@ -39,6 +52,14 @@ class RmaOrderLine(models.Model):
|
||||
valid_ids |= quant.lot_id
|
||||
if valid_ids:
|
||||
lots = valid_ids
|
||||
# Check if the lot has ever been shipped to that customer.
|
||||
# In that case restrict to those.
|
||||
mls = rec.env["stock.move.line"].search(
|
||||
rec._get_filter_lot_customer_domain()
|
||||
)
|
||||
moved_lots = mls.mapped("lot_id")
|
||||
if moved_lots:
|
||||
lots = lots.filtered(lambda l: l in moved_lots)
|
||||
rec.valid_lot_ids = lots
|
||||
|
||||
def _onchange_product_id(self):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<record id="view_rma_line_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.form</field>
|
||||
|
||||
Reference in New Issue
Block a user