From aad3671e28234e9e957305732c2ca656bb810bdf Mon Sep 17 00:00:00 2001 From: AlexPForgeFlow Date: Thu, 31 Oct 2024 17:28:16 +0100 Subject: [PATCH] [16.0][IMP] ddmrp: add RFQ qty info inside of the DLT Horizon --- ddmrp/models/stock_buffer.py | 20 +++++++++++--------- ddmrp/views/stock_buffer_view.xml | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ddmrp/models/stock_buffer.py b/ddmrp/models/stock_buffer.py index 19093bdfb..4d2ec9a7c 100644 --- a/ddmrp/models/stock_buffer.py +++ b/ddmrp/models/stock_buffer.py @@ -1196,6 +1196,12 @@ def _compute_product_vendor_code(self): help="Request for Quotation total quantity that is planned outside of " "the DLT horizon.", ) + rfq_inside_dlt_qty = fields.Float( + string="RFQ Qty (Inside DLT)", + readonly=True, + help="Request for Quotation total quantity that is planned inside of " + "the DLT horizon.", + ) net_flow_position = fields.Float( digits="Product Unit of Measure", readonly=True, @@ -1679,17 +1685,13 @@ def _calc_incoming_dlt_qty(self): outside_dlt_moves = self._search_stock_moves_incoming(outside_dlt=True) rec.incoming_outside_dlt_qty = sum(outside_dlt_moves.mapped("product_qty")) if rec.item_type == "purchased": - cut_date = rec._get_incoming_supply_date_limit() - # FIXME: filter using order_id.state while - # https://github.com/odoo/odoo/pull/58966 is not merged. - # Can be changed in v14. - pols = rec.purchase_line_ids.filtered( - lambda l: l.date_planned > fields.Datetime.to_datetime(cut_date) - and l.order_id.state in ("draft", "sent") - ) - rec.rfq_outside_dlt_qty = sum(pols.mapped("product_qty")) + pols_outside_dlt = rec._get_rfq_dlt(outside_dlt=True) + rec.rfq_outside_dlt_qty = sum(pols_outside_dlt.mapped("product_qty")) + pols_inside_dlt = rec._get_rfq_dlt() + rec.rfq_inside_dlt_qty = sum(pols_inside_dlt.mapped("product_qty")) else: rec.rfq_outside_dlt_qty = 0.0 + rec.rfq_inside_dlt_qty = 0.0 rec.incoming_total_qty = rec.incoming_dlt_qty + rec.incoming_outside_dlt_qty return True diff --git a/ddmrp/views/stock_buffer_view.xml b/ddmrp/views/stock_buffer_view.xml index 5993f6792..0b7a4ddad 100644 --- a/ddmrp/views/stock_buffer_view.xml +++ b/ddmrp/views/stock_buffer_view.xml @@ -89,6 +89,15 @@ type="object" attrs="{'invisible':[('rfq_outside_dlt_qty', '=', 0)]}" /> + +