summaryrefslogtreecommitdiff
path: root/addons/mrp/report/report_stock_forecasted.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/mrp/report/report_stock_forecasted.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/mrp/report/report_stock_forecasted.py')
-rw-r--r--addons/mrp/report/report_stock_forecasted.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/addons/mrp/report/report_stock_forecasted.py b/addons/mrp/report/report_stock_forecasted.py
new file mode 100644
index 00000000..0e403f97
--- /dev/null
+++ b/addons/mrp/report/report_stock_forecasted.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+
+class ReplenishmentReport(models.AbstractModel):
+ _inherit = 'report.stock.report_product_product_replenishment'
+
+ def _move_draft_domain(self, product_template_ids, product_variant_ids, wh_location_ids):
+ in_domain, out_domain = super()._move_draft_domain(product_template_ids, product_variant_ids, wh_location_ids)
+ in_domain += [('production_id', '=', False)]
+ out_domain += [('raw_material_production_id', '=', False)]
+ return in_domain, out_domain
+
+ def _compute_draft_quantity_count(self, product_template_ids, product_variant_ids, wh_location_ids):
+ res = super()._compute_draft_quantity_count(product_template_ids, product_variant_ids, wh_location_ids)
+ res['draft_production_qty'] = {}
+ domain = self._product_domain(product_template_ids, product_variant_ids)
+ domain += [('state', '=', 'draft')]
+
+ # Pending incoming quantity.
+ mo_domain = domain + [('location_dest_id', 'in', wh_location_ids)]
+ grouped_mo = self.env['mrp.production'].read_group(mo_domain, ['product_qty:sum'], 'product_id')
+ res['draft_production_qty']['in'] = sum(mo['product_qty'] for mo in grouped_mo)
+
+ # Pending outgoing quantity.
+ move_domain = domain + [
+ ('raw_material_production_id', '!=', False),
+ ('location_id', 'in', wh_location_ids),
+ ]
+ grouped_moves = self.env['stock.move'].read_group(move_domain, ['product_qty:sum'], 'product_id')
+ res['draft_production_qty']['out'] = sum(move['product_qty'] for move in grouped_moves)
+ res['qty']['in'] += res['draft_production_qty']['in']
+ res['qty']['out'] += res['draft_production_qty']['out']
+
+ return res