openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #06405
[Merge] lp:~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM into lp:ocb-addons
Mohammad Alhashash has proposed merging lp:~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM into lp:ocb-addons.
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1194640 in OpenERP Community Backports (Addons): "[stock][7.0][trunk] Available quantity field in production lots is not in product UoM and unit is not shown"
https://bugs.launchpad.net/ocb-addons/+bug/1194640
For more details, see:
https://code.launchpad.net/~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM/+merge/217682
--
https://code.launchpad.net/~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM/+merge/217682
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~alhashash/ocb-addons/7.0-bug-1194640-lot_qty_has_no_UoM into lp:ocb-addons.
=== 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 @@
'location_id': fields.many2one('stock.location', 'Location', readonly=True, select=True),
'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
'prodlot_id': fields.many2one('stock.production.lot', 'Serial Number', readonly=True, select=True),
+ 'uom_id': fields.many2one('product.uom', 'Unit of Measure'),
}
def init(self, cr):
drop_view_if_exists(cr, 'stock_report_prodlots')
cr.execute("""
- create or replace view stock_report_prodlots as (
- select max(id) as id,
- location_id,
- product_id,
- prodlot_id,
- sum(qty) as qty
- from (
- select -max(sm.id) as id,
- sm.location_id,
- sm.product_id,
- sm.prodlot_id,
- -sum(sm.product_qty /uo.factor) as qty
- from stock_move as sm
- left join stock_location sl
- on (sl.id = sm.location_id)
- left join product_uom uo
- on (uo.id=sm.product_uom)
- where state = 'done'
- group by sm.location_id, sm.product_id, sm.product_uom, sm.prodlot_id
- union all
- select max(sm.id) as id,
- sm.location_dest_id as location_id,
- sm.product_id,
- sm.prodlot_id,
- sum(sm.product_qty /uo.factor) as qty
- from stock_move as sm
- left join stock_location sl
- on (sl.id = sm.location_dest_id)
- left join product_uom uo
- on (uo.id=sm.product_uom)
- where sm.state = 'done'
- group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.prodlot_id
- ) as report
- group by location_id, product_id, prodlot_id
- )""")
+ CREATE OR REPLACE VIEW stock_report_prodlots
+ AS
+ SELECT max (report.id) AS id,
+ report.location_id,
+ report.product_id,
+ report.prodlot_id,
+ sum (report.qty) * um.factor AS qty,
+ pt.uom_id
+ FROM ( SELECT -max (sm.id) AS id,
+ sm.location_id,
+ sm.product_id,
+ sm.prodlot_id,
+ -sum (sm.product_qty / uo.factor) AS qty
+ FROM stock_move sm
+ LEFT JOIN stock_location sl ON sl.id = sm.location_id
+ LEFT JOIN product_uom uo ON uo.id = sm.product_uom
+ WHERE sm.state::text = 'done'::text
+ GROUP BY sm.location_id,
+ sm.product_id,
+ sm.product_uom,
+ sm.prodlot_id
+ UNION ALL
+ SELECT max (sm.id) AS id,
+ sm.location_dest_id AS location_id,
+ sm.product_id,
+ sm.prodlot_id,
+ sum (sm.product_qty / uo.factor) AS qty
+ FROM stock_move sm
+ LEFT JOIN stock_location sl ON sl.id = sm.location_dest_id
+ LEFT JOIN product_uom uo ON uo.id = sm.product_uom
+ WHERE sm.state::text = 'done'::text
+ GROUP BY sm.location_dest_id,
+ sm.product_id,
+ sm.product_uom,
+ sm.prodlot_id) report
+ LEFT JOIN product_product p ON p.id = report.product_id
+ LEFT JOIN product_template pt ON pt.id = p.product_tmpl_id
+ LEFT JOIN product_uom um ON um.id = pt.uom_id
+ GROUP BY report.location_id,
+ report.product_id,
+ pt.uom_id,
+ um.factor,
+ report.prodlot_id;
+ """)
def unlink(self, cr, uid, ids, context=None):
raise osv.except_osv(_('Error!'), _('You cannot delete any record!'))
=== 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 @@
'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'),
'company_id': fields.many2one('res.company', 'Company', select=True),
'move_ids': fields.one2many('stock.move', 'prodlot_id', 'Moves for this serial number', readonly=True),
+ 'uom_id': fields.related('product_id', 'uom_id', type='many2one', relation='product.uom', string='Unit of Measure', readonly=True),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
=== 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 @@
</group>
<group>
<field name="date"/>
- <field name="stock_available"/>
+ <label for="stock_available"/>
+ <div>
+ <field name="stock_available" class="oe_inline"/>
+ <field name="uom_id" class="oe_inline"/>
+ </div>
</group>
</group>
<notebook>
@@ -397,6 +401,7 @@
<field name="ref"/>
<field name="product_id"/>
<field name="stock_available"/>
+ <field name="uom_id"/>
<field name="date"/>
</tree>
</field>
Follow ups