[IMP] stock: adapt views of current inventory valuation and stock level forecast

The stock level forecast view should have inverse columns and rows.  The line graph
is also better by default.

The stock valuation view should only be in reporting (removed the graph part) and is replaced by a pivot and
graph view of the quants in the warehouse menu.  We only group by location by default.

Use date_expected instead of date in stock level forecast and group dates by week by default.
This commit is contained in:
Josse Colpaert
2015-03-27 15:59:31 +01:00
parent 2f29acf9c5
commit ba435bc3a9
5 changed files with 46 additions and 35 deletions
+6 -6
View File
@@ -38,7 +38,7 @@ class report_stock_forecast(models.Model):
END AS date,
SUM(sq.qty) AS product_qty
FROM
(SELECT min(date) AS date FROM stock_move AS sm
(SELECT min(date_expected) AS date FROM stock_move AS sm
LEFT JOIN
stock_location source_location ON sm.location_id = source_location.id
LEFT JOIN
@@ -59,7 +59,7 @@ class report_stock_forecast(models.Model):
SELECT
max(sm.id) as id,
sm.product_id,
to_date(to_char(sm.date, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date,
to_date(to_char(sm.date_expected, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date,
SUM(sm.product_qty) AS product_qty
FROM
stock_move as sm
@@ -72,12 +72,12 @@ class report_stock_forecast(models.Model):
WHERE
sm.state IN ('confirmed','assigned','waiting') and
source_location.usage != 'internal' and dest_location.usage = 'internal'
GROUP BY sm.date,sm.product_id
GROUP BY sm.date_expected,sm.product_id
UNION ALL
SELECT
max(sm.id) as id,
sm.product_id,
to_date(to_char(sm.date, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date,
to_date(to_char(sm.date_expected, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date,
SUM(-(sm.product_qty)) AS product_qty
FROM
stock_move as sm
@@ -90,7 +90,7 @@ class report_stock_forecast(models.Model):
WHERE
sm.state IN ('confirmed','assigned','waiting') and
source_location.usage = 'internal' and dest_location.usage != 'internal'
GROUP BY sm.date,sm.product_id)
GROUP BY sm.date_expected,sm.product_id)
as MAIN
LEFT JOIN
(SELECT DISTINCT date
@@ -98,7 +98,7 @@ class report_stock_forecast(models.Model):
(
SELECT CURRENT_DATE AS DATE
UNION ALL
SELECT to_date(to_char(sm.date, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date
SELECT to_date(to_char(sm.date_expected, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date
FROM stock_move sm
LEFT JOIN
stock_location source_location ON sm.location_id = source_location.id
@@ -6,8 +6,7 @@
<field name="model">report.stock.forecast</field>
<field name="arch" type="xml">
<pivot string="Stock Level forecast" disable_linking="True">
<field name="product_id" type="col"/>
<field name="cumulative_quantity" type="measure"/>
<field name="product_id" type="row"/>
<field name="quantity" type="measure"/>
</pivot>
</field>
@@ -17,7 +16,7 @@
<field name="name">Stock.forecast.graph</field>
<field name="model">report.stock.forecast</field>
<field name="arch" type="xml">
<graph string="Stock Level forecast" type="pivot">
<graph string="Stock Level forecast" type="line">
<field name="product_id" type="col"/>
<field name="cumulative_quantity" type="measure"/>
</graph>
@@ -32,8 +31,8 @@
<field name="product_id"/>
<field name="date"/>
<group expand="1" string="Group By">
<filter string="Pivot" name="pivot_by" context="{'pivot_row_groupby': ['date:day'], 'pivot_column_groupby': ['product_id'],'pivot_measures': ['cumulative_quantity','quantity']}"/>
<filter string="Graph" name="graph_by" context="{'graph_groupbys': ['date:day', 'product_id']}"/>
<filter string="Pivot" name="pivot_by" context="{'pivot_row_groupby': ['product_id'], 'pivot_column_groupby': ['date:week'],'pivot_measures': ['quantity']}"/>
<filter string="Graph" name="graph_by" context="{'graph_groupbys': ['date:week', 'product_id']}"/>
</group>
</search>
</field>
+34 -8
View File
@@ -1687,6 +1687,10 @@
<field name="owner_id" groups="stock.group_tracking_owner"/>
<group expand='0' string='Filters'>
<filter name='internal_loc' string="Internal Locations" domain="[('location_id.usage','=', 'internal')]"/>
<filter name='transit_loc' string="Transit Locations" domain="[('location_id.usage' ,'=', 'transit')]"/>
<separator/>
<filter name="negative" string="Negative" domain="[('qty', '&lt;', 0.0)]"/>
<filter name="positive" string="Positive" domain="[('qty', '&gt;', 0.0)]"/>
</group>
<group expand='0' string='Group by...'>
<filter name="productgroup" string='Product' context="{'group_by' : 'product_id'}"/>
@@ -1705,8 +1709,18 @@
<field name="name">Quants</field>
<field name="res_model">stock.quant</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="help">This analysis gives you a fast overview on the current stock level of your products and their today's inventory value.</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_internal_loc': 1, 'group_by': ['product_id', 'location_id']}</field>
<field name="help">This analysis gives you a fast overview on the current stock level of your products and their current inventory value.</field>
</record>
<record model="ir.actions.act_window" id="action_quantsinv">
<field name="name">Current Inventory</field>
<field name="res_model">stock.quant</field>
<field name="view_type">form</field>
<field name="view_mode">pivot,graph</field>
<field name="context">{'search_default_internal_loc': 1}</field>
<field name="help">This analysis gives you a fast overview on the current stock level of your products and their current inventory value.</field>
</record>
<record model="ir.ui.view" id="view_stock_quant_form">
@@ -1759,19 +1773,31 @@
</field>
</record>
<record model="ir.ui.view" id="view_stock_quant_graph_value">
<record model="ir.ui.view" id="view_stock_quant_graph_value">
<field name="name">stock.quant.graph</field>
<field name="model">stock.quant</field>
<field eval="12" name="priority"/>
<field name="arch" type="xml">
<graph string="Quants">
<field name="product_id"/>
<field name="qty"/>
<field name="location_id"/>
<graph string="Quants" type="pie">
<field name="product_id" type="row"/>
<field name="qty" type="measure"/>
<field name="inventory_value" type="measure"/>
</graph>
</field>
</record>
<record model="ir.ui.view" id="view_stock_quant_pivot">
<field name="name">stock.quant.pivot</field>
<field name="model">stock.quant</field>
<field name="arch" type="xml">
<pivot string="Inventory">
<field name="product_id" type="row"/>
<field name="qty" type="measure"/>
<field name="inventory_value" type="measure"/>
</pivot>
</field>
</record>
<!-- Procurements are located in Warehouse menu hierarchy, MRP users should come to Stock application to use it. -->
<menuitem id="menu_stock_sched" name="Schedulers" parent="stock.menu_stock_root" sequence="3" groups="stock.group_stock_manager"/>
<menuitem action="action_procurement_compute" id="menu_procurement_compute" parent="menu_stock_sched" groups="base.group_no_one" sequence="2"/>
@@ -1784,7 +1810,7 @@
<menuitem id="menu_procurement_rules" name="Global Procurement Rules" parent="stock.menu_routes_config" action="procrules" groups="base.group_no_one" sequence="3"/>
<menuitem id="menu_stock_location_path" name="Global Push Rules" parent="stock.menu_routes_config" action="stolocpath" groups="base.group_no_one" sequence="4"/>
<menuitem id="menu_pickingtype" name="Operations Types" parent="stock.menu_warehouse_config" action="action_picking_type_list" sequence="4"/>
<menuitem action="action_quantsinv" id="menu_action_quants_inv" parent="stock.menu_stock_inventory_control" sequence="20"/>
<record model="ir.actions.act_window" id="product_open_orderpoint">
<field name="context">{'default_product_id': active_id, 'search_default_product_id': active_id}</field>
@@ -29,7 +29,7 @@ class wizard_valuation_history(osv.osv_memory):
'domain': "[('date', '<=', '" + data['date'] + "')]",
'name': _('Stock Value At Date'),
'view_type': 'form',
'view_mode': 'tree,graph',
'view_mode': 'tree',
'res_model': 'stock.history',
'type': 'ir.actions.act_window',
'context': ctx,
@@ -51,7 +51,7 @@
<field name="source"/>
<field name="quantity" sum="# of Products "/>
<field name="inventory_value" sum="Total Value"/>
</tree>
</tree>
</field>
</record>
<record id="view_stock_history_report_pivot" model="ir.ui.view">
@@ -94,20 +94,6 @@
</search>
</field>
</record>
<record id="action_history_tree" model="ir.actions.act_window">
<field name="name">Current Inventory</field>
<field name="res_model">stock.history</field>
<field name="type">ir.actions.act_window</field>
<field name="domain">[('date','&lt;=',time.strftime('%Y-%m-%d %H:%M:%S'))]</field>
<field name="view_type">form</field>
<field name="view_mode">tree,pivot,graph</field>
</record>
<menuitem action="action_history_tree"
id="menu_action_history_tree"
parent="stock.menu_stock_inventory_control"
groups="stock.group_locations"
sequence="20"/>
</data>
</openerp>