fix: Prevent unit conversion in production schedule view state when use_all_schedules is true for replenishment calculations.

This commit is contained in:
Suherdy Yacob 2026-02-18 14:29:55 +07:00
parent ebef032f0e
commit 3b19d279ff

View File

@ -9,6 +9,12 @@ class MrpProductionSchedule(models.Model):
def get_production_schedule_view_state(self, period_scale=False, use_all_schedules=False):
res = super().get_production_schedule_view_state(period_scale, use_all_schedules)
for state in res:
# When use_all_schedules is True, it means we are in the context of replenishment calculation
# (action_replenish -> get_production_schedule_view_state), so we should NOT convert units
# because the system expects base units for procurement.
if use_all_schedules:
continue
mps = self.browse(state['id'])
if mps.packaging_id:
packaging_qty = mps.packaging_id.qty