diff options
| author | Rémy Voet (ryv) <ryv@odoo.com> | 2020-09-11 15:25:14 +0000 |
|---|---|---|
| committer | Rémy Voet (ryv) <ryv@odoo.com> | 2020-09-11 15:25:14 +0000 |
| commit | 87b16dab35c2326220d5bbd51bb7f07e876352d1 (patch) | |
| tree | 83a30b2b05ff5e6f1ce6d678adc0b452594230ba | |
| parent | 450e0ec45005c3d6c2e8475e134113a7d8515e9f (diff) | |
[FIX] stock: forecasted take the reservation in account
Add reservation information in the forecasted report.
Also this information is used by the forecasted information in
stock move.
closes odoo/odoo#57562
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
| -rw-r--r-- | addons/stock/report/report_stock_forecasted.py | 16 | ||||
| -rw-r--r-- | addons/stock/report/report_stock_forecasted.xml | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/addons/stock/report/report_stock_forecasted.py b/addons/stock/report/report_stock_forecasted.py index f9ffe29e46c..bb4dcc5c9a6 100644 --- a/addons/stock/report/report_stock_forecasted.py +++ b/addons/stock/report/report_stock_forecasted.py @@ -109,7 +109,7 @@ class ReplenishmentReport(models.AbstractModel): res['lines'] = self._get_report_lines(product_template_ids, product_variant_ids, wh_location_ids) return res - def _prepare_report_line(self, quantity, move_out=None, move_in=None, replenishment_filled=True, product=False): + def _prepare_report_line(self, quantity, move_out=None, move_in=None, replenishment_filled=True, product=False, reservation=False): timezone = self._context.get('tz') product = product or (move_out.product_id if move_out else move_in.product_id) is_late = move_out.date < move_in.date if (move_out and move_in) else False @@ -128,6 +128,7 @@ class ReplenishmentReport(models.AbstractModel): 'quantity': quantity, 'move_out': move_out, 'move_in': move_in, + 'reservation': reservation, } def _get_report_lines(self, product_template_ids, product_variant_ids, wh_location_ids): @@ -147,9 +148,20 @@ class ReplenishmentReport(models.AbstractModel): lines = [] for product in (ins | outs).product_id: for out in outs_per_product[product.id]: + if out.state not in ('partially_available', 'assigned'): + continue + current = currents[out.product_id.id] + reserved = out.product_uom._compute_quantity(out.reserved_availability, product.uom_id) + currents[product.id] -= reserved + lines.append(self._prepare_report_line(reserved, move_out=out, reservation=True)) + + for out in outs_per_product[product.id]: # Reconcile with the current stock. current = currents[out.product_id.id] - demand = out.product_qty + reserved = 0.0 + if out.state in ('partially_available', 'assigned'): + reserved = out.product_uom._compute_quantity(out.reserved_availability, product.uom_id) + demand = out.product_qty - reserved taken_from_stock = min(demand, current) if not float_is_zero(taken_from_stock, precision_rounding=product.uom_id.rounding): currents[product.id] -= taken_from_stock diff --git a/addons/stock/report/report_stock_forecasted.xml b/addons/stock/report/report_stock_forecasted.xml index 0bbe734791b..61748f6c020 100644 --- a/addons/stock/report/report_stock_forecasted.xml +++ b/addons/stock/report/report_stock_forecasted.xml @@ -117,6 +117,9 @@ class="font-weight-bold" view-type="form" t-att-res-model="line['document_in']._name" t-att-res-id="line['document_in'].id"/> + <t t-elif="line['reservation']"> + Reserved from stock + </t> <t t-elif="line['replenishment_filled']"> <t t-if="line['document_out']">Inventory On Hand</t> <t t-else="">Free Stock</t> |
