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 Oct 31, 2024
1 parent 5479a39 commit aad3671
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
20 changes: 11 additions & 9 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
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 RFQ quantities are inside of the DLT Horizon and may require rescheduling.
Press this button to display the involved RFQs"
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 RFQ quantities are inside of the DLT Horizon and may require rescheduling.
Press this button to display the involved RFQs"
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 aad3671

Please sign in to comment.