Skip to content

Commit

Permalink
[16.0][IMP] ddmrp: add RFQ qty info inside of the DLT Horizon
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPForgeFlow committed Nov 4, 2024
1 parent 5479a39 commit cb80faf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ddmrp/models/stock_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1843,12 +1845,12 @@ def _get_rfq_dlt(self, outside_dlt=False):
if not outside_dlt:
pols = self.purchase_line_ids.filtered(
lambda l: l.date_planned <= fields.Datetime.to_datetime(cut_date)
and l.state in ("draft", "sent")
and l.state in ("draft", "sent", "to approve")
)
else:
pols = self.purchase_line_ids.filtered(
lambda l: l.date_planned > fields.Datetime.to_datetime(cut_date)
and l.state in ("draft", "sent")
and l.state in ("draft", "sent", "to approve")
)
return pols

Expand Down
18 changes: 18 additions & 0 deletions ddmrp/views/stock_buffer_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@
type="object"
attrs="{'invisible':[('rfq_outside_dlt_qty', '=', 0)]}"
/>
<field name="rfq_inside_dlt_qty" invisible="1" />
<button
title="Some RFQs are inside of the DLT Horizon and waiting validation to be accounted into the NFP.
Press this button to display them."
name="action_view_supply_rfq_inside_dlt_window"
icon="fa-warning"
type="object"
attrs="{'invisible':[('rfq_inside_dlt_qty', '=', 0)]}"
/>
<button
title="No stock available in source location for distributed buffer"
name="action_dummy"
Expand Down Expand Up @@ -472,6 +481,15 @@
type="object"
attrs="{'invisible': ['|', ('qualified_demand', '=', 0), ('qualified_demand_mrp_move_ids', '=', [])]}"
/>
<field name="rfq_inside_dlt_qty" invisible="1" />
<button
title="Some RFQs are inside of the DLT Horizon and waiting validation to be accounted into the NFP.
Press this button to display them."
name="action_view_supply_rfq_inside_dlt_window"
icon="fa-warning"
type="object"
attrs="{'invisible':[('rfq_inside_dlt_qty', '=', 0)]}"
/>
</div>
<field name="net_flow_position" />
<label for="net_flow_position_percent" />
Expand Down

0 comments on commit cb80faf

Please sign in to comment.