diff --git a/partner_label/README.rst b/partner_label/README.rst new file mode 100644 index 000000000..5400e4bd5 --- /dev/null +++ b/partner_label/README.rst @@ -0,0 +1,67 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============== +Partner labels +============== + +This module was written to allow users to print address labels for partners. + +Configuration +============= + +To configure this module, you need to: + +#. go to `Settings / General settings` +#. scroll to header `Labels configuration` +#. change width, height, padding and margin to fit your label stickers, if necessary change the paper format +#. you can preview your changes by pressing the `Preview` button + +Usage +===== + +#. mark partners +#. print your labels + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/134/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Holger Brunn + +Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_label/__init__.py b/partner_label/__init__.py new file mode 100644 index 000000000..a3e818a49 --- /dev/null +++ b/partner_label/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/partner_label/__manifest__.py b/partner_label/__manifest__.py new file mode 100644 index 000000000..d2f65ac31 --- /dev/null +++ b/partner_label/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Partner labels", + "version": "10.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Base", + "summary": "Print partner labels", + "depends": [ + 'base_setup', + 'report', + ], + "data": [ + "views/base_config_settings.xml", + "reports/res_partner.xml", + ], + "installable": True, +} diff --git a/partner_label/models/__init__.py b/partner_label/models/__init__.py new file mode 100644 index 000000000..d7fc83e26 --- /dev/null +++ b/partner_label/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import res_company +from . import base_config_settings diff --git a/partner_label/models/base_config_settings.py b/partner_label/models/base_config_settings.py new file mode 100644 index 000000000..c60f648f1 --- /dev/null +++ b/partner_label/models/base_config_settings.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import api, fields, models + + +class BaseConfigSettings(models.TransientModel): + _inherit = 'base.config.settings' + + partner_labels_width = fields.Float( + related='company_id.partner_labels_width', required=True, + ) + partner_labels_height = fields.Float( + related='company_id.partner_labels_height', required=True, + ) + partner_labels_padding = fields.Float( + related='company_id.partner_labels_padding', required=True, + ) + partner_labels_margin = fields.Float( + related='company_id.partner_labels_margin', required=True, + ) + partner_labels_paperformat_id = fields.Many2one( + 'report.paperformat', string='Paperformat', required=True, + default=lambda self: self.env.ref( + 'partner_label.report_res_partner_label' + ).paperformat_id, + compute='_compute_partner_labels_paperformat_id', + inverse='_inverse_partner_labels_paperformat_id', + ) + + @api.multi + def _compute_partner_labels_paperformat_id(self): + for this in self: + this.partner_labels_paperformat_id = self.env.ref( + 'partner_label.report_res_partner_label' + ).paperformat_id + + @api.multi + def _inverse_partner_labels_paperformat_id(self): + for this in self: + self.env.ref( + 'partner_label.report_res_partner_label' + ).paperformat_id = this.partner_labels_paperformat_id + + @api.multi + def action_partner_labels_preview(self): + return self.env['report'].get_action( + self.env['res.partner'].search([], limit=100), + 'partner_label.view_res_partner_label', + ) diff --git a/partner_label/models/res_company.py b/partner_label/models/res_company.py new file mode 100644 index 000000000..9cc273ee4 --- /dev/null +++ b/partner_label/models/res_company.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import fields, models + + +class ResCompany(models.Model): + _inherit = 'res.company' + + partner_labels_width = fields.Float( + 'Width', default=60, help='Width in millimeters', required=True, + ) + partner_labels_height = fields.Float( + 'Height', default=42.3, help='Height in millimeters', required=True, + ) + partner_labels_padding = fields.Float( + 'Padding', default=5, help='Padding in millimeters', required=True, + ) + partner_labels_margin = fields.Float( + 'Margin', default=1, help='Margin in millimeters', required=True, + ) diff --git a/partner_label/reports/res_partner.xml b/partner_label/reports/res_partner.xml new file mode 100644 index 000000000..f1fee27f2 --- /dev/null +++ b/partner_label/reports/res_partner.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/partner_label/static/description/icon.png b/partner_label/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_label/static/description/icon.png differ diff --git a/partner_label/tests/__init__.py b/partner_label/tests/__init__.py new file mode 100644 index 000000000..43dacef09 --- /dev/null +++ b/partner_label/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_partner_label diff --git a/partner_label/tests/test_partner_label.py b/partner_label/tests/test_partner_label.py new file mode 100644 index 000000000..de7b90c3a --- /dev/null +++ b/partner_label/tests/test_partner_label.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp.tests.common import TransactionCase + + +class TestPartnerLabel(TransactionCase): + def test_partner_label(self): + settings = self.env['base.config.settings'].create({}) + self.assertItemsEqual( + settings.action_partner_labels_preview()['context']['active_ids'], + self.env['res.partner'].search([], limit=100).ids, + ) + self.assertEqual( + settings.partner_labels_paperformat_id, + self.env.ref('partner_label.report_res_partner_label') + .paperformat_id + ) + settings.partner_labels_paperformat_id = self.env.ref( + 'report.paperformat_us' + ).id, + self.assertEqual( + self.env.ref('partner_label.report_res_partner_label') + .paperformat_id, + self.env.ref('report.paperformat_us') + ) diff --git a/partner_label/views/base_config_settings.xml b/partner_label/views/base_config_settings.xml new file mode 100644 index 000000000..806815a5c --- /dev/null +++ b/partner_label/views/base_config_settings.xml @@ -0,0 +1,28 @@ + + + + + base.config.settings + + + + + + + + + +