openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #01962
lp:~camptocamp/carriers-deliveries/7.0-add-delivery_carrier_label_default_webkit-yvr into lp:carriers-deliveries
Yannick Vaucher @ Camptocamp has proposed merging lp:~camptocamp/carriers-deliveries/7.0-add-delivery_carrier_label_default_webkit-yvr into lp:carriers-deliveries with lp:~camptocamp/carriers-deliveries/7.0-add-base_delivery_carrier_label-yvr as a prerequisite.
Requested reviews:
Stock and Logistic Core Editors (stock-logistic-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/carriers-deliveries/7.0-add-delivery_carrier_label_default_webkit-yvr/+merge/198050
--
https://code.launchpad.net/~camptocamp/carriers-deliveries/7.0-add-delivery_carrier_label_default_webkit-yvr/+merge/198050
Your team Stock and Logistic Core Editors is requested to review the proposed merge of lp:~camptocamp/carriers-deliveries/7.0-add-delivery_carrier_label_default_webkit-yvr into lp:carriers-deliveries.
=== added directory 'delivery_carrier_label_default_webkit'
=== added file 'delivery_carrier_label_default_webkit/__init__.py'
--- delivery_carrier_label_default_webkit/__init__.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/__init__.py 2013-12-06 13:14:05 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from . import report
+from . import stock
=== added file 'delivery_carrier_label_default_webkit/__openerp__.py'
--- delivery_carrier_label_default_webkit/__openerp__.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/__openerp__.py 2013-12-06 13:14:05 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{'name': 'Module for carrier labels',
+ 'version': '1.0',
+ 'author': 'Camptocamp',
+ 'maintainer': 'Camptocamp',
+ 'category': 'version',
+ 'complexity': 'normal',
+ 'depends': [
+ 'base_delivery_carrier_label',
+ 'report_webkit',
+ ],
+ 'description': """
+This print a basic label using webkit library
+
+Contributors
+------------
+
+* Yannick Vaucher <yannick.vaucher@xxxxxxxxxxxxxx>
+
+ """,
+ 'website': 'http://www.camptocamp.com/',
+ 'data': ['reports.xml'],
+ 'tests': [],
+ 'installable': True,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': True}
=== added file 'delivery_carrier_label_default_webkit/delivery.py'
--- delivery_carrier_label_default_webkit/delivery.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/delivery.py 2013-12-06 13:14:05 +0000
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from openerp.osv import orm
+
+
+class delivery_carrier(orm.Model):
+ _inherit = 'delivery.carrier'
+
+ def _get_carrier_type_selection(self, cr, uid, context=None):
+ """ To inherit to add carrier type """
+ res = self.get_carrier_type_selection(cr, uid, context=context)
+ res.append(('standard', 'Standard'))
+ return res
=== added directory 'delivery_carrier_label_default_webkit/i18n'
=== added directory 'delivery_carrier_label_default_webkit/report'
=== added file 'delivery_carrier_label_default_webkit/report/__init__.py'
--- delivery_carrier_label_default_webkit/report/__init__.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/report/__init__.py 2013-12-06 13:14:05 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from . import shipping_label_report
=== added file 'delivery_carrier_label_default_webkit/report/shipping_label_report.py'
--- delivery_carrier_label_default_webkit/report/shipping_label_report.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/report/shipping_label_report.py 2013-12-06 13:14:05 +0000
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import time
+
+from openerp.report import report_sxw
+
+
+class ShippingLabelReport(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(ShippingLabelReport, self).__init__(cr, uid, name, context=context)
+ self.localcontext.update({
+ 'time': time,
+ 'cr': cr,
+ 'uid': uid,
+ })
+
+report_sxw.report_sxw('report.delivery.shipping_label',
+ 'stock.picking',
+ 'delivery_carrier_label_webkit/report/template/shipping_label.mako',
+ parser=ShippingLabelReport)
=== added directory 'delivery_carrier_label_default_webkit/report/template'
=== added file 'delivery_carrier_label_default_webkit/report/template/shipping_label.mako'
--- delivery_carrier_label_default_webkit/report/template/shipping_label.mako 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/report/template/shipping_label.mako 2013-12-06 13:14:05 +0000
@@ -0,0 +1,43 @@
+<html>
+ <head>
+ </head>
+ <body>
+ <%page expression_filter="entity"/>
+
+ <%def name="address(partner, commercial_partner=None)">
+ <% company_partner = False %>
+ %if commercial_partner:
+ %if commercial_partner.id != partner.id:
+ <% company_partner = commercial_partner %>
+ %endif
+ %elif partner.parent_id:
+ <% company_partner = partner.parent_id %>
+ %endif
+
+ %if company_partner:
+ <tr><td class="name">${company_partner.name or ''}</td></tr>
+ <tr><td>${partner.title and partner.title.name or ''} ${partner.name}</td></tr>
+ <% address_lines = partner.contact_address.split("\n")[1:] %>
+ %else:
+ <tr><td class="name">${partner.title and partner.title.name or ''} ${partner.name}</td></tr>
+ <% address_lines = partner.contact_address.split("\n") %>
+ %endif
+ %for part in address_lines:
+ %if part:
+ <tr><td>${part}</td></tr>
+ %endif
+ %endfor
+ </%def>
+
+ %for picking in objects:
+ <% partner = picking.partner_id %>
+ <% setLang(partner.lang) %>
+ <div class="address">
+ <table class="recipient">
+ ${address(partner=partner)}
+ </table>
+ </div>
+ %endfor
+
+ </body>
+</html>
=== added file 'delivery_carrier_label_default_webkit/reports.xml'
--- delivery_carrier_label_default_webkit/reports.xml 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/reports.xml 2013-12-06 13:14:05 +0000
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <report
+ auto="False"
+ id="delivery.shipping_label_webkit"
+ model="stock.picking"
+ name="delivery.shipping.label.webkit"
+ file="delivery_carrier_label_webkit/report/template/shipping_label.mako"
+ string="Shipping Label"
+ attachment_use="1"
+ multi="True"
+ webkit_header="base_headers_webkit.base_reports_portrait_header"
+ report_type="webkit"/>
+ </data>
+</openerp>
=== added file 'delivery_carrier_label_default_webkit/stock.py'
--- delivery_carrier_label_default_webkit/stock.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_default_webkit/stock.py 2013-12-06 13:14:05 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from openerp.osv import orm
+from openerp.netsvc import Service
+
+
+class stock_picking_out(orm.Model):
+ _inherit = 'stock.picking.out'
+
+ def generate_default_label(self, cr, uid, ids, context=None):
+ """
+ Generate a label from a webkit report
+ """
+ assert len(ids) == 1
+ report_obj = self.pool.get('ir.actions.report.xml')
+ ir_model_data_obj = self.pool.get('ir.model.data')
+
+ __, report_id = ir_model_data_obj.get_object_reference(
+ cr, uid, 'delivery', 'shipping_label_webkit')
+
+ report = report_obj.browse(cr, uid, report_id, context=context)
+
+ data = {'ids': ids}
+ report_parser = Service._services['report.%s' % report.report_name]
+ return report_parser.create_single_pdf(cr, uid, ids, data, report, context=context)[0]
Follow ups