diff --git a/stock_picking_webkit/__openerp__.py b/stock_picking_webkit/__openerp__.py index 70a40ec..f83aed9 100644 --- a/stock_picking_webkit/__openerp__.py +++ b/stock_picking_webkit/__openerp__.py @@ -3,6 +3,8 @@ # # Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) # @author Nicolas Bessi +# Copyright (c) 2013 Agile Business Group (http://www.agilebg.com) +# @author Lorenzo Battistini # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,11 +22,15 @@ ############################################################################## { - 'name': 'Picking report using Webkit Library', + 'name': 'Picking reports using Webkit Library', 'version': '1.0', 'category': 'Reports/Webkit', 'description': """ -Replaces the legacy rml picking Order report by a brand new webkit report. +Replaces the legacy rml picking Order report by brand new webkit reports. +Three reports are provided: + - Aggregated pickings + - Aggregated deliveries + - Delivery Slip """, 'author': 'Camptocamp', 'website': 'http://www.openerp.com', diff --git a/stock_picking_webkit/report.xml b/stock_picking_webkit/report.xml index 805014b..b42c6d2 100644 --- a/stock_picking_webkit/report.xml +++ b/stock_picking_webkit/report.xml @@ -20,6 +20,15 @@ report_type="webkit" header="False" webkit_header="base_headers_webkit.base_minimum_reports_portrait_header" /> + diff --git a/stock_picking_webkit/report/delivery_slip.mako b/stock_picking_webkit/report/delivery_slip.mako new file mode 100644 index 0000000..9f0b950 --- /dev/null +++ b/stock_picking_webkit/report/delivery_slip.mako @@ -0,0 +1,97 @@ + + + + + + + <%page expression_filter="entity"/> + <% + def carriage_returns(text): + return text.replace('\n', '
') + %> + %for picking in objects: + <% setLang(picking.partner_id.lang) %> +
+ + %if picking.partner_id.parent_id: + + + <% address_lines = picking.partner_id.contact_address.split("\n")[1:] %> + %else: + + <% address_lines = picking.partner_id.contact_address.split("\n") %> + %endif + %for part in address_lines: + %if part: + + %endif + %endfor +
${picking.partner_id.parent_id.name or ''}
${picking.partner_id.title and picking.partner_id.title.name or ''} ${picking.partner_id.name }
${picking.partner_id.title and picking.partner_id.title.name or ''} ${picking.partner_id.name }
${part}
+ <% + invoice_addr = invoice_address(picking) + %> + + + + %if invoice_addr.contact_address: + <% address_lines = invoice_addr.contact_address.split("\n") %> + %for part in address_lines: + %if part: + + %endif + %endfor + %endif +
${_("Invoice address:")}
${invoice_addr.title and invoice_addr.title.name or ''} ${invoice_addr.name }
${part}
+
+ +

${_(u'Delivery Order') } ${picking.name}

+ + + + + + + + + + + + + + + + + + +
${_("Contact")}${_("Origin")}${_("Scheduled Date")}${_('Weight')}${_('Delivery Method')}${_('Incoterm')}
${user.name}${picking.origin or ''}${formatLang(picking.min_date, date=True)}${picking.weight}${picking.carrier_id and picking.carrier_id.name or ''}${picking.sale_id and picking.sale_id.incoterm and picking.sale_id.incoterm.name or ''}
+ + + + + + + + + + + %for line in picking.move_lines: + + + + + + %endfor +
${_("Description")}${_("Serial Number")}${_("Quantity")}
${ line.name }${ line.prodlot_id and line.prodlot_id.name or ''}${ formatLang(line.product_qty) } ${line.product_uom.name}
+ +
+ %if picking.note : +

${picking.note | carriage_returns}

+ %endif + +

+
+ %endfor + + diff --git a/stock_picking_webkit/report/stock_report.py b/stock_picking_webkit/report/stock_report.py index af5bd81..4561a71 100644 --- a/stock_picking_webkit/report/stock_report.py +++ b/stock_picking_webkit/report/stock_report.py @@ -3,6 +3,8 @@ # # Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) # @author Nicolas Bessi +# Copyright (c) 2013 Agile Business Group (http://www.agilebg.com) +# @author Lorenzo Battistini # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,6 +23,7 @@ import operator from report import report_sxw import pooler +import time class NullMove(object): """helper class to generate empty lines in the delivery report""" @@ -114,6 +117,26 @@ class PrintPick(report_sxw.rml_parse): objects.append(PickingAgregation(agr[0], agr[1], agreg[agr])) return super(PrintPick, self).set_context(objects, data, ids, report_type=report_type) + +class DeliverySlip(report_sxw.rml_parse): + + def _get_invoice_address(self, picking): + if picking.sale_id: + return picking.sale_id.partner_invoice_id + partner_obj = self.pool.get('res.partner') + invoice_address_id = picking.partner_id.address_get( + adr_pref=['invoice'] + )['invoice'] + return partner_obj.browse( + self.cr, self.uid, invoice_address_id) + + def __init__(self, cr, uid, name, context): + super(DeliverySlip, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'invoice_address': self._get_invoice_address, + }) + report_sxw.report_sxw('report.webkit.aggregated_picking', 'stock.picking', 'addons/stock_picking_webkit/report/picking.html.mako', @@ -123,3 +146,8 @@ report_sxw.report_sxw('report.webkit.aggregated_delivery', 'stock.picking', 'addons/stock_picking_webkit/report/delivery.html.mako', parser=PrintPick) + +report_sxw.report_sxw('report.webkit.delivery_slip', + 'stock.picking', + 'addons/stock_picking_webkit/report/delivery_slip.mako', + parser=DeliverySlip)