Merge pull request #287 from ForgeFlow/14.0-rma_filter_lot-imp

[14.0][IMP] rma_filter_lot: add possibility to select only the lots issued specifically to the customer of the RMA.
This commit is contained in:
Jordi Ballester Alomar
2022-07-26 18:32:13 +02:00
committed by GitHub
4 changed files with 25 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ Contributors
* Mateu Griful <mateu.griful@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>
* Jordi Ballester <jordi.ballester@forgeflow.com>
Maintainers
~~~~~~~~~~~

View File

@@ -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,
}

View File

@@ -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):

View File

@@ -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>