Merge lp:~numerigraphe-team/openobject-addons/trunk-wms-stock-latest-move into lp:~openerp-dev/openobject-addons/trunk-wms

Proposed by Lionel Sausin - Initiatives/Numérigraphe
Status: Merged
Merged at revision: 9648
Proposed branch: lp:~numerigraphe-team/openobject-addons/trunk-wms-stock-latest-move
Merge into: lp:~openerp-dev/openobject-addons/trunk-wms
Diff against target: 99 lines (+21/-13)
2 files modified
stock/report/report_stock.py (+13/-8)
stock/report/report_stock_view.xml (+8/-5)
To merge this branch: bzr merge lp:~numerigraphe-team/openobject-addons/trunk-wms-stock-latest-move
Reviewer Review Type Date Requested Status
OpenERP R&D Team Pending
Review via email: mp+211059@code.launchpad.net

This proposal supersedes a proposal from 2014-03-13.

Description of the change

This branch improves the report model "latest inventory date", by showing the latest Stock Move as well.
This helps users isolate unused products that may deserve special measures like discount sales or quality control.
It also optimizes the SQL query a bit, and let users filter inactive products or not.

This branch is unchanged from the v7.0 proposal, only includes the current trunk-wms for Runbot.
It runs green: http://runbot.openerp.com/numerigraphe-team-trunk-wms-stock-latest-move-30937/logs/

To post a comment you must log in.
Revision history for this message
qdp (OpenERP) (qdp) wrote :

i merged it in revision 9648 even if, to be honnest, i'm not sure the add of latest stock move date is worth the join with stock_move table. I trusted you on this. ;-)

thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/report/report_stock.py'
2--- stock/report/report_stock.py 2013-11-29 16:56:44 +0000
3+++ stock/report/report_stock.py 2014-03-18 14:01:45 +0000
4@@ -25,13 +25,15 @@
5
6 class report_stock_lines_date(osv.osv):
7 _name = "report.stock.lines.date"
8- _description = "Dates of Inventories"
9+ _description = "Dates of Inventories and latest Moves"
10 _auto = False
11 _order = "date"
12 _columns = {
13- 'id': fields.integer('Inventory Line Id', readonly=True),
14+ 'id': fields.integer('Product Id', readonly=True),
15 'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
16- 'date': fields.datetime('Latest Inventory Date'),
17+ 'date': fields.datetime('Date of latest Inventory', readonly=True),
18+ 'move_date': fields.datetime('Date of latest Stock Move', readonly=True),
19+ "active" : fields.boolean("Active", readonly=True),
20 }
21 def init(self, cr):
22 drop_view_if_exists(cr, 'report_stock_lines_date')
23@@ -40,13 +42,16 @@
24 select
25 p.id as id,
26 p.id as product_id,
27- max(s.date) as date
28+ max(s.date) as date,
29+ max(m.date) as move_date,
30+ p.active as active
31 from
32 product_product p
33- left outer join stock_inventory_line l on (p.id=l.product_id)
34- left join stock_inventory s on (l.inventory_id=s.id)
35- and s.state = 'done'
36- where p.active='true'
37+ left join (
38+ stock_inventory_line l
39+ inner join stock_inventory s on (l.inventory_id=s.id and s.state = 'done')
40+ ) on (p.id=l.product_id)
41+ left join stock_move m on (m.product_id=p.id and m.state = 'done')
42 group by p.id
43 )""")
44
45
46=== modified file 'stock/report/report_stock_view.xml'
47--- stock/report/report_stock_view.xml 2013-11-29 16:56:44 +0000
48+++ stock/report/report_stock_view.xml 2014-03-18 14:01:45 +0000
49@@ -10,6 +10,7 @@
50 <tree string="Dates of Inventories" create="false">
51 <field name="product_id"/>
52 <field name="date" />
53+ <field name="move_date"/>
54 </tree>
55 </field>
56 </record>
57@@ -18,12 +19,13 @@
58 <field name="name">report.stock.lines.date.search</field>
59 <field name="model">report.stock.lines.date</field>
60 <field name="arch" type="xml">
61- <search string="Dates of Inventories">
62+ <search string="Dates of Inventories &amp; Moves">
63 <field name="date"/>
64 <filter icon="terp-accessories-archiver" name="stockable" string="Stockable" domain="[('product_id.type','=', 'product')]"/>
65 <filter icon="terp-accessories-archiver" string="Consumable" domain="[('product_id.type','=', 'consu')]"/>
66 <separator/>
67- <filter icon="terp-accessories-archiver-minus" string="Non Inv" domain="[('date','=', False)]"/>
68+ <filter icon="terp-accessories-archiver-minus" string="No Inventory yet" domain="[('date','=', False)]"/>
69+ <filter icon="terp-accessories-archiver-minus" string="No Stock Move yet" domain="[('move_date','=', False)]"/>
70 <field name="product_id"/>
71 </search>
72 </field>
73@@ -33,22 +35,23 @@
74 <field name="name">report.stock.lines.date.form</field>
75 <field name="model">report.stock.lines.date</field>
76 <field name="arch" type="xml">
77- <form string="Dates of Inventories" version="7.0">
78+ <form string="Dates of Inventories &amp; Moves" version="7.0">
79 <group>
80 <field name="product_id"/>
81 <field name="date"/>
82+ <field name="move_date"/>
83 </group>
84 </form>
85 </field>
86 </record>
87
88 <record model="ir.actions.act_window" id="action_stock_line_date">
89- <field name="name">Last Product Inventories</field>
90+ <field name="name">Latest Inventories &amp; Moves</field>
91 <field name="res_model">report.stock.lines.date</field>
92 <field name="view_type">form</field>
93 <field name="context">{'search_default_stockable':1}</field>
94 <field name="view_mode">tree,form</field>
95- <field name="help">Display the last inventories done on your products and easily sort them with specific filtering criteria. If you do frequent and partial inventories, you need this report in order to ensure that the stock of each product is controlled at least once a year.</field>
96+ <field name="help">Display the latest Inventories and Moves done on your products and easily sort them with specific filtering criteria. If you do frequent and partial inventories, you need this report in order to ensure that the stock of each product is controlled at least once a year. This also lets you find out which products have seen little move lately and may deserve special measures (discounted sale, quality control...)</field>
97 </record>
98
99 <menuitem parent="next_id_61" action="action_stock_line_date" id="menu_report_stock_line_date" sequence="2"/>