← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~numerigraphe-team/ocb-addons/7.0-stock-latest-move into lp:ocb-addons

 

Lionel Sausin - Numérigraphe has proposed merging lp:~numerigraphe-team/ocb-addons/7.0-stock-latest-move into lp:ocb-addons.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1291986 in OpenERP Community Backports (Addons): ""Last Product Inventories" could show the last move's date too"
  https://bugs.launchpad.net/ocb-addons/+bug/1291986

For more details, see:
https://code.launchpad.net/~numerigraphe-team/ocb-addons/7.0-stock-latest-move/+merge/210795

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.

For the moment it is still portable as-is to trunk-WMS and v8 and has been proposed upstream: https://code.launchpad.net/~numerigraphe-team/openobject-addons/7.0-stock-latest-move/+merge/210792

Even though this does change the database structure, I do not foresee any migration problem even using OpenERP SA's migration bot because itt is only a view report.
-- 
https://code.launchpad.net/~numerigraphe-team/ocb-addons/7.0-stock-latest-move/+merge/210795
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~numerigraphe-team/ocb-addons/7.0-stock-latest-move into lp:ocb-addons.
=== modified file 'stock/report/report_stock.py'
--- stock/report/report_stock.py	2012-10-23 16:05:04 +0000
+++ stock/report/report_stock.py	2014-03-13 13:47:24 +0000
@@ -137,13 +137,15 @@
 
 class report_stock_lines_date(osv.osv):
     _name = "report.stock.lines.date"
-    _description = "Dates of Inventories"
+    _description = "Dates of Inventories and latest Moves"
     _auto = False
     _order = "date"
     _columns = {
-        'id': fields.integer('Inventory Line Id', readonly=True),
+        'id': fields.integer('Product Id', readonly=True),
         'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
-        'date': fields.datetime('Latest Inventory Date'),
+        'date': fields.datetime('Date of latest Inventory', readonly=True),
+        'move_date': fields.datetime('Date of latest Stock Move', readonly=True),
+        "active" : fields.boolean("Active", readonly=True),
     }
     def init(self, cr):
         drop_view_if_exists(cr, 'report_stock_lines_date')
@@ -152,13 +154,16 @@
                 select
                 p.id as id,
                 p.id as product_id,
-                max(s.date) as date
+                max(s.date) as date,
+                max(m.date) as move_date,
+				p.active as active
             from
                 product_product p
-                    left outer join stock_inventory_line l on (p.id=l.product_id)
-                    left join stock_inventory s on (l.inventory_id=s.id)
-                and s.state = 'done'
-                where p.active='true'
+                    left join (
+                        stock_inventory_line l
+                        inner join stock_inventory s on (l.inventory_id=s.id and s.state = 'done')
+                    ) on (p.id=l.product_id)
+                    left join stock_move m on (m.product_id=p.id and m.state = 'done')
                 group by p.id
             )""")
 

=== modified file 'stock/report/report_stock_view.xml'
--- stock/report/report_stock_view.xml	2012-10-23 16:05:04 +0000
+++ stock/report/report_stock_view.xml	2014-03-13 13:47:24 +0000
@@ -23,6 +23,7 @@
                 <tree string="Dates of Inventories" create="false">
                     <field name="product_id"/>
                     <field name="date" />
+                    <field name="move_date"/>
                 </tree>
             </field>
         </record>
@@ -31,12 +32,13 @@
             <field name="name">report.stock.lines.date.search</field>
             <field name="model">report.stock.lines.date</field>
             <field name="arch" type="xml">
-                <search string="Dates of Inventories">
+                <search string="Dates of Inventories &amp; Moves">
                     <field name="date"/>
                     <filter icon="terp-accessories-archiver" name="stockable" string="Stockable" domain="[('product_id.type','=', 'product')]"/>
                     <filter icon="terp-accessories-archiver" string="Consumable" domain="[('product_id.type','=', 'consu')]"/>
                     <separator/>
-                    <filter icon="terp-accessories-archiver-minus" string="Non Inv" domain="[('date','=', False)]"/>
+                    <filter icon="terp-accessories-archiver-minus" string="No Inventory yet" domain="[('date','=', False)]"/>
+                    <filter icon="terp-accessories-archiver-minus" string="No Stock Move yet" domain="[('move_date','=', False)]"/>
                     <field name="product_id"/>
                 </search>
             </field>
@@ -46,22 +48,23 @@
             <field name="name">report.stock.lines.date.form</field>
             <field name="model">report.stock.lines.date</field>
             <field name="arch" type="xml">
-                <form string="Dates of Inventories" version="7.0">
+                <form string="Dates of Inventories &amp; Moves" version="7.0">
                     <group>
                         <field name="product_id"/>
                         <field name="date"/>
+                        <field name="move_date"/>
                     </group>
                 </form>
             </field>
         </record>
 
         <record model="ir.actions.act_window" id="action_stock_line_date">
-            <field name="name">Last Product Inventories</field>
+            <field name="name">Latest Inventories &amp; Moves</field>
             <field name="res_model">report.stock.lines.date</field>
             <field name="view_type">form</field>
              <field name="context">{'search_default_stockable':1}</field>
             <field name="view_mode">tree,form</field>
-            <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>
+            <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>
         </record>
 
         <menuitem parent="next_id_61" action="action_stock_line_date" id="menu_report_stock_line_date" sequence="2"/>


References