From ac83efee614b3a716be02bb350c98a17630ea5c6 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 23 Dec 2013 15:26:46 +0100 Subject: [PATCH] [IMP] stock, internal picking list report: added putaway/removal strategies features in the internal picking report bzr revid: qdp-launchpad@openerp.com-20131223142646-msgy0ts2vdm4c3dy --- addons/stock/report/picking.py | 57 ++++++++- addons/stock/report/picking_internal.rml | 152 ++++++++++++++++------- 2 files changed, 160 insertions(+), 49 deletions(-) diff --git a/addons/stock/report/picking.py b/addons/stock/report/picking.py index ae4b6416125..ce901a8b92e 100644 --- a/addons/stock/report/picking.py +++ b/addons/stock/report/picking.py @@ -21,12 +21,15 @@ import time from openerp.report import report_sxw +from openerp.tools.translate import _ class picking(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(picking, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, + 'get_internal_picking_src_lines': self.get_internal_picking_src_lines, + 'get_internal_picking_dest_lines': self.get_internal_picking_dest_lines, 'get_product_desc': self.get_product_desc, }) def get_product_desc(self, move_line): @@ -35,6 +38,56 @@ class picking(report_sxw.rml_parse): desc = '[' + move_line.product_id.default_code + ']' + ' ' + desc return desc -report_sxw.report_sxw('report.stock.picking.list','stock.picking','addons/stock/report/picking.rml',parser=picking) -report_sxw.report_sxw('report.stock.picking.list.internal','stock.picking','addons/stock/report/picking_internal.rml',parser=picking, header='internal') + def get_internal_picking_src_lines(self, picking): + res = [] + for line in picking.move_lines: + if line.state not in ('confirmed', 'done', 'assigned', 'waiting') or line.scrapped: + continue + state_label = line.state == 'done' and _('Done') or (line.state == 'confirmed' and _('Waiting Availability') or (line.state == 'assigned' and _('Available') or _('Waiting Availability'))) + row = { + 'state': state_label, + 'description': self.get_product_desc(line), + } + if not line.lot_ids: + row['quantity'] = line.product_uom_qty + row['lot_id'] = '' + row['uom'] = line.product_uom.name + row['location_id'] = line.location_id.name + row['barcode'] = line.product_id.ean13 + res.append(row) + else: + for quant in line.lot_ids: + row2 = row.copy() + row2['quantity'] = quant.qty + row2['uom'] = line.product_id.uom_id.name + row2['location_id'] = quant.location_id.name + row2['lot_id'] = quant.lot_id and quant.lot_id.name or '' + row2['barcode'] = quant.lot_id and quant.lot_id.name or line.product_id.ean13 + res.append(row2) + return res + + def get_internal_picking_dest_lines(self, picking): + res = [] + for line in picking.move_lines: + row = {'description': self.get_product_desc(line)} + if not line.putaway_ids: + row['quantity'] = line.product_uom_qty + row['uom'] = line.product_uom.name + row['location_id'] = line.location_dest_id.name + row['barcode'] = line.product_id.ean13 + row['lot_id'] = '' + res.append(row) + else: + for rec in line.putaway_ids: + row2 = row.copy() + row2['quantity'] = rec.quantity + row2['uom'] = line.product_id.uom_id.name + row2['location_id'] = rec.location_id.name + row2['lot_id'] = rec.lot_id and rec.lot_id.name or '' + row2['barcode'] = rec.lot_id and rec.lot_id.name or line.product_id.ean13 + res.append(row2) + return res + +report_sxw.report_sxw('report.stock.picking.list', 'stock.picking', 'addons/stock/report/picking.rml', parser=picking) +report_sxw.report_sxw('report.stock.picking.list.internal', 'stock.picking', 'addons/stock/report/picking_internal.rml', parser=picking, header='internal') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/report/picking_internal.rml b/addons/stock/report/picking_internal.rml index ba5754a93c9..83c412c8e68 100644 --- a/addons/stock/report/picking_internal.rml +++ b/addons/stock/report/picking_internal.rml @@ -68,16 +68,6 @@ - - - - - - - - - - @@ -139,17 +129,17 @@ Description - - Lot - Status - Location + Quantity - Quantity + Source Location + + + Serial Number Barcode @@ -218,80 +208,74 @@ - + Description - Serial Number - - - Status - - - Location + Status Quantity + + Source Location + + + Serial Number + Barcode
- [[ repeatIn([line for line in picking.move_lines if ((line.state == 'confirmed' or line.state=='done' or line.state=='assigned') and not line.scrapped)],'move_lines') ]] - [[ (picking.move_lines!=[] and removeParentNode('para')) or removeParentNode('section')]] - + [[ repeatIn(get_internal_picking_src_lines(picking), 'move_line') ]] + - [[ get_product_desc(move_lines) ]] + [[ move_line['description'] ]] - [[ move_lines.quant_ids and ','.join(map(str, [q.lot_id.name for q in move_lines.quant_ids if q.lot_id])) or '' ]] + [[ move_line['state'] ]] - Waiting Availability[[ move_lines.state == 'confirmed' and ' ' or removeParentNode('para') ]] - Done[[ move_lines.state == 'done' and ' ' or removeParentNode('para') ]] - Available[[ move_lines.state == 'assigned' and ' ' or removeParentNode('para') ]] + [[ move_line['quantity'] ]] [[ move_line['uom'] ]] - [[ (move_lines.location_id and move_lines.location_id.name) or '' ]] + [[ move_line['location_id'] ]] - [[ formatLang(move_lines.product_qty) ]] [[ move_lines.product_uom.name ]] + [[ move_line['lot_id'] ]] - [[ move_lines.product_id.ean13 or removeParentNode('barCode')]] + [[ move_line['barcode'] or removeParentNode('barCode')]]
- [[ ([line for line in picking.move_lines if (line.state == 'draft' or line.state=='waiting' )]) and 'Non Assigned Products:' or removeParentNode('para') ]] + [[ ([line for line in picking.move_lines if line.state == 'draft']) and 'Non Assigned Products:' or removeParentNode('para') ]]
- [[ repeatIn([line for line in picking.move_lines if (line.state == 'draft' or line.state=='waiting')],'move_lines') ]] - [[ (picking.move_lines!=[] and removeParentNode('para')) or removeParentNode('section')]] - + [[ repeatIn([line for line in picking.move_lines if line.state == 'draft'],'move_lines') ]] + [[ get_product_desc(move_lines) ]] - [[ (move_lines.prodlot_id and move_lines.prodlot_id.name) or '' ]] - - - [[ (picking.picking_type_id.code == 'incoming' or removeParentNode('para')) ]][[ move_lines.state == 'done' and 'Received' or move_lines.state]] - [[ (picking.picking_type_id.code == 'outgoing' or removeParentNode('para')) ]][[ move_lines.state == 'done' and 'Delivered' or move_lines.state]] - [[ (picking.picking_type_id.code == 'internal' or removeParentNode('para')) ]][[ move_lines.state == 'done' and 'Transferred' or move_lines.state]] - - - [[ (move_lines.location_id and move_lines.location_id.name) or '' ]] + Unconfirmed [[ formatLang(move_lines.product_qty) ]] [[ move_lines.product_uom.name ]] + + [[ move_lines.location_id.name ]] + + + + [[ move_lines.product_id.ean13 or removeParentNode('barCode')]] @@ -302,5 +286,79 @@ + + + + + + Description + + + Quantity + + + Suggested Destination + + + Serial Number + + + Barcode + + + + + + + + + + + Suggested Destination Locations + + + + + + + Description + + + Quantity + + + Suggested Destination + + + Serial Number + + + Barcode + + + +
+ [[ repeatIn(get_internal_picking_dest_lines(picking), 'move_line') ]] + + + + [[ move_line['description'] ]] + + + [[ move_line['quantity'] ]] [[ move_line['uom'] ]] + + + [[ move_line['location_id'] ]] + + + [[ move_line['lot_id'] ]] + + + [[ move_line['barcode'] or removeParentNode('barCode')]] + + + +
+