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
1=== modified file 'stock/report/report_stock.py'
2--- stock/report/report_stock.py 2014-04-25 13:12:38 +0000
3+++ stock/report/report_stock.py 2014-04-29 20:30:31 +0000
4@@ -33,46 +33,56 @@
5 'location_id': fields.many2one('stock.location', 'Location', readonly=True, select=True),
6 'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
7 'prodlot_id': fields.many2one('stock.production.lot', 'Serial Number', readonly=True, select=True),
8+ 'uom_id': fields.many2one('product.uom', 'Unit of Measure'),
9 }
10
11 def init(self, cr):
12 drop_view_if_exists(cr, 'stock_report_prodlots')
13 cr.execute("""
14- create or replace view stock_report_prodlots as (
15- select max(id) as id,
16- location_id,
17- product_id,
18- prodlot_id,
19- sum(qty) as qty
20- from (
21- select -max(sm.id) as id,
22- sm.location_id,
23- sm.product_id,
24- sm.prodlot_id,
25- -sum(sm.product_qty /uo.factor) as qty
26- from stock_move as sm
27- left join stock_location sl
28- on (sl.id = sm.location_id)
29- left join product_uom uo
30- on (uo.id=sm.product_uom)
31- where state = 'done'
32- group by sm.location_id, sm.product_id, sm.product_uom, sm.prodlot_id
33- union all
34- select max(sm.id) as id,
35- sm.location_dest_id as location_id,
36- sm.product_id,
37- sm.prodlot_id,
38- sum(sm.product_qty /uo.factor) as qty
39- from stock_move as sm
40- left join stock_location sl
41- on (sl.id = sm.location_dest_id)
42- left join product_uom uo
43- on (uo.id=sm.product_uom)
44- where sm.state = 'done'
45- group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.prodlot_id
46- ) as report
47- group by location_id, product_id, prodlot_id
48- )""")
49+ CREATE OR REPLACE VIEW stock_report_prodlots
50+ AS
51+ SELECT max (report.id) AS id,
52+ report.location_id,
53+ report.product_id,
54+ report.prodlot_id,
55+ sum (report.qty) * um.factor AS qty,
56+ pt.uom_id
57+ FROM ( SELECT -max (sm.id) AS id,
58+ sm.location_id,
59+ sm.product_id,
60+ sm.prodlot_id,
61+ -sum (sm.product_qty / uo.factor) AS qty
62+ FROM stock_move sm
63+ LEFT JOIN stock_location sl ON sl.id = sm.location_id
64+ LEFT JOIN product_uom uo ON uo.id = sm.product_uom
65+ WHERE sm.state::text = 'done'::text
66+ GROUP BY sm.location_id,
67+ sm.product_id,
68+ sm.product_uom,
69+ sm.prodlot_id
70+ UNION ALL
71+ SELECT max (sm.id) AS id,
72+ sm.location_dest_id AS location_id,
73+ sm.product_id,
74+ sm.prodlot_id,
75+ sum (sm.product_qty / uo.factor) AS qty
76+ FROM stock_move sm
77+ LEFT JOIN stock_location sl ON sl.id = sm.location_dest_id
78+ LEFT JOIN product_uom uo ON uo.id = sm.product_uom
79+ WHERE sm.state::text = 'done'::text
80+ GROUP BY sm.location_dest_id,
81+ sm.product_id,
82+ sm.product_uom,
83+ sm.prodlot_id) report
84+ LEFT JOIN product_product p ON p.id = report.product_id
85+ LEFT JOIN product_template pt ON pt.id = p.product_tmpl_id
86+ LEFT JOIN product_uom um ON um.id = pt.uom_id
87+ GROUP BY report.location_id,
88+ report.product_id,
89+ pt.uom_id,
90+ um.factor,
91+ report.prodlot_id;
92+ """)
93
94 def unlink(self, cr, uid, ids, context=None):
95 raise osv.except_osv(_('Error!'), _('You cannot delete any record!'))
96
97=== modified file 'stock/stock.py'
98--- stock/stock.py 2014-04-25 12:47:14 +0000
99+++ stock/stock.py 2014-04-29 20:30:31 +0000
100@@ -1505,6 +1505,7 @@
101 'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'),
102 'company_id': fields.many2one('res.company', 'Company', select=True),
103 'move_ids': fields.one2many('stock.move', 'prodlot_id', 'Moves for this serial number', readonly=True),
104+ 'uom_id': fields.related('product_id', 'uom_id', type='many2one', relation='product.uom', string='Unit of Measure', readonly=True),
105 }
106 _defaults = {
107 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
108
109=== modified file 'stock/stock_view.xml'
110--- stock/stock_view.xml 2014-04-29 08:31:08 +0000
111+++ stock/stock_view.xml 2014-04-29 20:30:31 +0000
112@@ -359,7 +359,11 @@
113 </group>
114 <group>
115 <field name="date"/>
116- <field name="stock_available"/>
117+ <label for="stock_available"/>
118+ <div>
119+ <field name="stock_available" class="oe_inline"/>
120+ <field name="uom_id" class="oe_inline"/>
121+ </div>
122 </group>
123 </group>
124 <notebook>
125@@ -397,6 +401,7 @@
126 <field name="ref"/>
127 <field name="product_id"/>
128 <field name="stock_available"/>
129+ <field name="uom_id"/>
130 <field name="date"/>
131 </tree>
132 </field>