Merge lp:~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM into lp:ocb-addons

Proposed by Mohammad Alhashash
Status: Rejected
Rejected by: Holger Brunn (Therp)
Proposed branch: lp:~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM
Merge into: lp:ocb-addons
Diff against target: 132 lines (+52/-36)
3 files modified
stock/report/report_stock.py (+45/-35)
stock/stock.py (+1/-0)
stock/stock_view.xml (+6/-1)
To merge this branch: bzr merge lp:~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Disapprove
Review via email: mp+217682@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Development for 7.0 has moved to github on https://github.com/OCA/ocb - please move your merge proposal there if it is still valid.

(I close and reject this in order to have a cleaner overview for 6.1 MPs which indeed have to be done on launchpad)

review: Disapprove

Unmerged revisions

10156. By Mohammad Alhashash

OCB Fix for lp:1194640 production lots quantity is not in product UoM and unit is not shown

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'stock/report/report_stock.py'
--- stock/report/report_stock.py 2014-04-25 13:12:38 +0000
+++ stock/report/report_stock.py 2014-04-29 20:30:31 +0000
@@ -33,46 +33,56 @@
33 'location_id': fields.many2one('stock.location', 'Location', readonly=True, select=True),33 'location_id': fields.many2one('stock.location', 'Location', readonly=True, select=True),
34 'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),34 'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
35 'prodlot_id': fields.many2one('stock.production.lot', 'Serial Number', readonly=True, select=True),35 'prodlot_id': fields.many2one('stock.production.lot', 'Serial Number', readonly=True, select=True),
36 'uom_id': fields.many2one('product.uom', 'Unit of Measure'),
36 }37 }
3738
38 def init(self, cr):39 def init(self, cr):
39 drop_view_if_exists(cr, 'stock_report_prodlots')40 drop_view_if_exists(cr, 'stock_report_prodlots')
40 cr.execute("""41 cr.execute("""
41 create or replace view stock_report_prodlots as (42 CREATE OR REPLACE VIEW stock_report_prodlots
42 select max(id) as id,43 AS
43 location_id,44 SELECT max (report.id) AS id,
44 product_id,45 report.location_id,
45 prodlot_id,46 report.product_id,
46 sum(qty) as qty47 report.prodlot_id,
47 from (48 sum (report.qty) * um.factor AS qty,
48 select -max(sm.id) as id,49 pt.uom_id
49 sm.location_id,50 FROM ( SELECT -max (sm.id) AS id,
50 sm.product_id,51 sm.location_id,
51 sm.prodlot_id,52 sm.product_id,
52 -sum(sm.product_qty /uo.factor) as qty53 sm.prodlot_id,
53 from stock_move as sm54 -sum (sm.product_qty / uo.factor) AS qty
54 left join stock_location sl55 FROM stock_move sm
55 on (sl.id = sm.location_id)56 LEFT JOIN stock_location sl ON sl.id = sm.location_id
56 left join product_uom uo57 LEFT JOIN product_uom uo ON uo.id = sm.product_uom
57 on (uo.id=sm.product_uom)58 WHERE sm.state::text = 'done'::text
58 where state = 'done'59 GROUP BY sm.location_id,
59 group by sm.location_id, sm.product_id, sm.product_uom, sm.prodlot_id60 sm.product_id,
60 union all61 sm.product_uom,
61 select max(sm.id) as id,62 sm.prodlot_id
62 sm.location_dest_id as location_id,63 UNION ALL
63 sm.product_id,64 SELECT max (sm.id) AS id,
64 sm.prodlot_id,65 sm.location_dest_id AS location_id,
65 sum(sm.product_qty /uo.factor) as qty66 sm.product_id,
66 from stock_move as sm67 sm.prodlot_id,
67 left join stock_location sl68 sum (sm.product_qty / uo.factor) AS qty
68 on (sl.id = sm.location_dest_id)69 FROM stock_move sm
69 left join product_uom uo70 LEFT JOIN stock_location sl ON sl.id = sm.location_dest_id
70 on (uo.id=sm.product_uom)71 LEFT JOIN product_uom uo ON uo.id = sm.product_uom
71 where sm.state = 'done'72 WHERE sm.state::text = 'done'::text
72 group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.prodlot_id73 GROUP BY sm.location_dest_id,
73 ) as report74 sm.product_id,
74 group by location_id, product_id, prodlot_id75 sm.product_uom,
75 )""")76 sm.prodlot_id) report
77 LEFT JOIN product_product p ON p.id = report.product_id
78 LEFT JOIN product_template pt ON pt.id = p.product_tmpl_id
79 LEFT JOIN product_uom um ON um.id = pt.uom_id
80 GROUP BY report.location_id,
81 report.product_id,
82 pt.uom_id,
83 um.factor,
84 report.prodlot_id;
85 """)
7686
77 def unlink(self, cr, uid, ids, context=None):87 def unlink(self, cr, uid, ids, context=None):
78 raise osv.except_osv(_('Error!'), _('You cannot delete any record!'))88 raise osv.except_osv(_('Error!'), _('You cannot delete any record!'))
7989
=== modified file 'stock/stock.py'
--- stock/stock.py 2014-04-25 12:47:14 +0000
+++ stock/stock.py 2014-04-29 20:30:31 +0000
@@ -1505,6 +1505,7 @@
1505 'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'),1505 'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'),
1506 'company_id': fields.many2one('res.company', 'Company', select=True),1506 'company_id': fields.many2one('res.company', 'Company', select=True),
1507 'move_ids': fields.one2many('stock.move', 'prodlot_id', 'Moves for this serial number', readonly=True),1507 'move_ids': fields.one2many('stock.move', 'prodlot_id', 'Moves for this serial number', readonly=True),
1508 'uom_id': fields.related('product_id', 'uom_id', type='many2one', relation='product.uom', string='Unit of Measure', readonly=True),
1508 }1509 }
1509 _defaults = {1510 _defaults = {
1510 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),1511 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
15111512
=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml 2014-04-29 08:31:08 +0000
+++ stock/stock_view.xml 2014-04-29 20:30:31 +0000
@@ -359,7 +359,11 @@
359 </group>359 </group>
360 <group>360 <group>
361 <field name="date"/>361 <field name="date"/>
362 <field name="stock_available"/>362 <label for="stock_available"/>
363 <div>
364 <field name="stock_available" class="oe_inline"/>
365 <field name="uom_id" class="oe_inline"/>
366 </div>
363 </group>367 </group>
364 </group>368 </group>
365 <notebook>369 <notebook>
@@ -397,6 +401,7 @@
397 <field name="ref"/>401 <field name="ref"/>
398 <field name="product_id"/>402 <field name="product_id"/>
399 <field name="stock_available"/>403 <field name="stock_available"/>
404 <field name="uom_id"/>
400 <field name="date"/>405 <field name="date"/>
401 </tree>406 </tree>
402 </field>407 </field>