mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[stock_analysis_forecast] Add incoming_quantity and outgoing_quantity
This commit is contained in:
@@ -17,6 +17,8 @@ class ReportStockForecast(models.Model):
|
||||
product_id = fields.Many2one(
|
||||
'product.product', string='Product', readonly=True)
|
||||
quantity = fields.Float(readonly=True)
|
||||
incoming_quantity = fields.Float(readonly=True)
|
||||
outgoing_quantity = fields.Float(readonly=True)
|
||||
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'report_stock_forecast')
|
||||
@@ -24,14 +26,20 @@ class ReportStockForecast(models.Model):
|
||||
MIN(id) as id,
|
||||
product_id as product_id,
|
||||
date as date,
|
||||
sum(product_qty) AS quantity
|
||||
sum(product_qty) AS quantity,
|
||||
sum(in_quantity) AS incoming_quantity,
|
||||
sum(out_quantity) AS outgoing_quantity
|
||||
FROM
|
||||
(SELECT
|
||||
MIN(id) as id,
|
||||
MAIN.product_id as product_id,
|
||||
SUB.date as date,
|
||||
CASE WHEN MAIN.date = SUB.date
|
||||
THEN sum(MAIN.product_qty) ELSE 0 END as product_qty
|
||||
THEN sum(MAIN.product_qty) ELSE 0 END as product_qty,
|
||||
CASE WHEN MAIN.date = SUB.date
|
||||
THEN sum(MAIN.in_quantity) ELSE 0 END as in_quantity,
|
||||
CASE WHEN MAIN.date = SUB.date
|
||||
THEN sum(MAIN.out_quantity) ELSE 0 END as out_quantity
|
||||
FROM
|
||||
(SELECT
|
||||
MIN(sq.id) as id,
|
||||
@@ -40,7 +48,9 @@ class ReportStockForecast(models.Model):
|
||||
'week',
|
||||
to_date(to_char(CURRENT_DATE, 'YYYY/MM/DD'),
|
||||
'YYYY/MM/DD')) as date,
|
||||
SUM(sq.qty) AS product_qty
|
||||
SUM(sq.qty) AS product_qty,
|
||||
0 AS in_quantity,
|
||||
0 AS out_quantity
|
||||
FROM
|
||||
stock_quant as sq
|
||||
LEFT JOIN
|
||||
@@ -64,7 +74,9 @@ class ReportStockForecast(models.Model):
|
||||
to_date(
|
||||
to_char(CURRENT_DATE, 'YYYY/MM/DD'), 'YYYY/MM/DD')) END
|
||||
AS date,
|
||||
SUM(sm.product_qty) AS product_qty
|
||||
SUM(sm.product_qty) AS product_qty,
|
||||
SUM(sm.product_qty) AS in_quantity,
|
||||
0 AS out_quantity
|
||||
FROM
|
||||
stock_move as sm
|
||||
LEFT JOIN
|
||||
@@ -94,7 +106,9 @@ class ReportStockForecast(models.Model):
|
||||
to_date(to_char(CURRENT_DATE, 'YYYY/MM/DD'),
|
||||
'YYYY/MM/DD')) END
|
||||
AS date,
|
||||
SUM(-(sm.product_qty)) AS product_qty
|
||||
SUM(-(sm.product_qty)) AS product_qty,
|
||||
0 AS in_quantity,
|
||||
SUM(sm.product_qty) AS out_quantity
|
||||
FROM
|
||||
stock_move as sm
|
||||
LEFT JOIN
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<graph string="Stock Level forecast" type="pivot" stacked="True">
|
||||
<field name="product_id" type="row"/>
|
||||
<field name="quantity" type="measure"/>
|
||||
<field name="incoming_quantity" type="measure"/>
|
||||
<field name="outgoing_quantity" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
@@ -25,7 +27,10 @@
|
||||
<field name="product_id"/>
|
||||
<field name="date"/>
|
||||
<group expand="1" string="Group By">
|
||||
<filter string="Pivot" name="pivot_by" context="{'row_group_by': ['product_id'], 'col_group_by': ['date:week'],'measures': ['quantity']}"/>
|
||||
<filter string="Pivot" name="pivot_by"
|
||||
context="{'row_group_by': ['product_id'],
|
||||
'col_group_by': ['date:week'],
|
||||
'measures': ['quantity', 'incoming_quantity', 'outgoing_quantity']}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user