diff --git a/delivery_carrier_label_batch/__openerp__.py b/delivery_carrier_label_batch/__manifest__.py similarity index 81% rename from delivery_carrier_label_batch/__openerp__.py rename to delivery_carrier_label_batch/__manifest__.py index 6ae079dfeb..dd4dc79f8d 100644 --- a/delivery_carrier_label_batch/__openerp__.py +++ b/delivery_carrier_label_batch/__manifest__.py @@ -1,21 +1,19 @@ -# -*- coding: utf-8 -*- -# Copyright 2013-2016 Camptocamp SA +# Copyright 2013-2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) { 'name': 'Carrier labels - Stock Batch Picking (link)', - 'version': '9.0.1.0.0', + 'version': '12.0.1.0.0', 'author': "Camptocamp,Odoo Community Association (OCA)", 'maintainer': 'Camptocamp', 'category': 'Carrier', 'complexity': 'normal', 'depends': ['base_delivery_carrier_label', 'stock_batch_picking'], - 'website': 'http://www.camptocamp.com/', + 'website': 'http://github.com/OCA/delivery-carrier', 'data': [ 'views/stock_batch_picking.xml', 'wizard/generate_labels_view.xml', 'wizard/apply_carrier_view.xml', ], - 'tests': [], 'installable': True, 'auto_install': True, 'license': 'AGPL-3', diff --git a/delivery_carrier_label_batch/models/stock_batch_picking.py b/delivery_carrier_label_batch/models/stock_batch_picking.py index 2f79f999c5..1de266d701 100644 --- a/delivery_carrier_label_batch/models/stock_batch_picking.py +++ b/delivery_carrier_label_batch/models/stock_batch_picking.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# Copyright 2013-2016 Camptocamp SA +# Copyright 2013-2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from openerp import _, api, fields, models +from odoo import _, api, fields, models class StockBatchPicking(models.Model): diff --git a/delivery_carrier_label_batch/pdf_utils.py b/delivery_carrier_label_batch/pdf_utils.py index c9ebfcbcf1..574799168c 100644 --- a/delivery_carrier_label_batch/pdf_utils.py +++ b/delivery_carrier_label_batch/pdf_utils.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# Copyright 2013-2016 Camptocamp SA +# Copyright 2013-2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from StringIO import StringIO +from io import BytesIO, StringIO from PyPDF2 import PdfFileReader, PdfFileWriter @@ -28,6 +27,6 @@ def assemble_pdf(pdf_list): for page in range(reader.getNumPages()): output.addPage(reader.getPage(page)) - s = StringIO() + s = BytesIO() output.write(s) return s.getvalue() diff --git a/delivery_carrier_label_batch/readme/CONTRIBUTORS.rst b/delivery_carrier_label_batch/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..477abbd46c --- /dev/null +++ b/delivery_carrier_label_batch/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Yannick Vaucher diff --git a/delivery_carrier_label_batch/readme/DESCRIPTION.rst b/delivery_carrier_label_batch/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..2cc8df90ce --- /dev/null +++ b/delivery_carrier_label_batch/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +This module adds a wizard on picking batch to generate the labels +of the packs. The labels are merged in one PDF file. + +If you want multiple labels for one picking, all the moves should have been +put in a pack before the labels can be printed. + +If you don't define your pack it will be considered a picking is a single pack. diff --git a/delivery_carrier_label_batch/readme/USAGE.rst b/delivery_carrier_label_batch/readme/USAGE.rst new file mode 100644 index 0000000000..159a06ebd4 --- /dev/null +++ b/delivery_carrier_label_batch/readme/USAGE.rst @@ -0,0 +1,3 @@ +To use this module, you need to: + + 1. Go to... diff --git a/delivery_carrier_label_batch/tests/__init__.py b/delivery_carrier_label_batch/tests/__init__.py index 1bcac6e22f..debab96f90 100644 --- a/delivery_carrier_label_batch/tests/__init__.py +++ b/delivery_carrier_label_batch/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # Author: Yannick Vaucher diff --git a/delivery_carrier_label_batch/tests/test_generate_labels.py b/delivery_carrier_label_batch/tests/test_generate_labels.py index 2e5a64bd6a..87ffe2bd6d 100644 --- a/delivery_carrier_label_batch/tests/test_generate_labels.py +++ b/delivery_carrier_label_batch/tests/test_generate_labels.py @@ -1,8 +1,9 @@ -# -*- coding: utf-8 -*- -# Copyright 2013-2016 Camptocamp SA +# Copyright 2013-2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -import openerp.tests.common as common -from openerp.modules import get_module_resource +import base64 + +import odoo.tests.common as common +from odoo.modules import get_module_resource class TestGenerateLabels(common.TransactionCase): @@ -41,8 +42,8 @@ def setUp(self): Move.create( {'name': '/', 'picking_id': picking_out_1.id, - 'product_id': self.ref('product.product_product_33'), - 'product_uom': self.ref('product.product_uom_unit'), + 'product_id': self.ref('product.product_delivery_01'), + 'product_uom': self.ref('uom.product_uom_unit'), 'product_uom_qty': 2, 'location_id': self.ref('stock.stock_location_14'), 'location_dest_id': self.ref('stock.stock_location_7'), @@ -51,8 +52,8 @@ def setUp(self): Move.create( {'name': '/', 'picking_id': picking_out_2.id, - 'product_id': self.ref('product.product_product_33'), - 'product_uom': self.ref('product.product_uom_unit'), + 'product_id': self.ref('product.product_delivery_01'), + 'product_uom': self.ref('uom.product_uom_unit'), 'product_uom_qty': 1, 'location_id': self.ref('stock.stock_location_14'), 'location_dest_id': self.ref('stock.stock_location_7'), @@ -61,14 +62,14 @@ def setUp(self): label = '' dummy_pdf_path = get_module_resource('delivery_carrier_label_batch', 'tests', 'dummy.pdf') - with file(dummy_pdf_path) as dummy_pdf: + with open(dummy_pdf_path, 'rb') as dummy_pdf: label = dummy_pdf.read() ShippingLabel.create( {'name': 'picking_out_1', 'res_id': picking_out_1.id, 'res_model': 'stock.picking', - 'datas': label.encode('base64'), + 'datas': base64.b64encode(label), 'file_type': 'pdf', }) @@ -76,7 +77,7 @@ def setUp(self): {'name': 'picking_out_2', 'res_id': picking_out_2.id, 'res_model': 'stock.picking', - 'datas': label.encode('base64'), + 'datas': base64.b64encode(label), 'file_type': 'pdf', }) @@ -97,7 +98,7 @@ def test_00_action_generate_labels(self): ('res_id', '=', self.batch.id)] ) - self.assertEquals(len(attachment), 1) + self.assertEqual(len(attachment), 1) self.assertTrue(attachment.datas) self.assertTrue(attachment.name, 'demo_prep001.pdf') self.assertTrue(attachment.mimetype, 'application/pdf') diff --git a/delivery_carrier_label_batch/views/stock_batch_picking.xml b/delivery_carrier_label_batch/views/stock_batch_picking.xml index 0cf3d39a62..dc3f2a9319 100644 --- a/delivery_carrier_label_batch/views/stock_batch_picking.xml +++ b/delivery_carrier_label_batch/views/stock_batch_picking.xml @@ -14,7 +14,7 @@ -