Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddmrp/models/stock_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ def _calc_adu_future_demand(self):
elif self.adu_calculation_method.source_future == "actual":
domain = self._future_moves_domain(date_from, date_to, locations)
for [total] in self.env["stock.move"]._read_group(
domain, aggregates=["product_uom_qty:sum"]
domain, aggregates=["product_qty:sum"]
):
qty += total or 0.0
return qty / horizon
Expand Down
23 changes: 23 additions & 0 deletions ddmrp/tests/test_ddmrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,3 +1533,26 @@ def test_50_chart_execution_no_product_no_crash(self):
data = json.loads(form.ddmrp_chart_execution)
self.assertEqual(data["div"], "")
self.assertEqual(data["script"], "")

def test_51_adu_calculation_future_actual_move_uom(self):
"""Future actual demand is aggregated in the product UoM.

A move expressed in a secondary UoM (Dozen) must contribute its
product-UoM quantity to the ADU, not its move-UoM quantity.
"""
method = self.aducalcmethodModel.create(
{
"name": "Future actual demand (120 days)",
"method": "future",
"source_future": "actual",
"horizon_future": 120,
"company_id": self.main_company.id,
}
)
self.buffer_a.adu_calculation_method = method.id
days = 30
date_move = self.calendar.plan_days(+1 * days + 1, datetime.today())
self.create_pickingoutA(date_move, 5, uom=self.dozen_unit)
self.bufferModel.cron_ddmrp_adu()
# 5 Dozen = 60 Units over the 120-day horizon
self.assertEqual(self.buffer_a.adu, 60 / 120)
Loading