diff --git a/report_label/README.rst b/report_label/README.rst new file mode 100644 index 000000000..7fffe66b2 --- /dev/null +++ b/report_label/README.rst @@ -0,0 +1,125 @@ +============= +Report Labels +============= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github + :target: https://github.com/OCA/reporting-engine/tree/14.0/report_label + :alt: OCA/reporting-engine +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-report_label + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/143/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to create self-adhesive label printing actions on any model. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Go to **Settings > Technical > Analysis > Label Paper Format** and create +your self-adhesive label paper formats. + +.. image:: https://raw.githubusercontent.com/OCA/reporting-engine/14.0/report_label/static/description/configure_paperformat.png + +Go to **Settings > Technical > Analysis > Label Report** and create your label +report, and its context action. You'll also need to create or reuse a +QWeb template for you label. + +.. image:: https://raw.githubusercontent.com/OCA/reporting-engine/14.0/report_label/static/description/configure_report_label.png + +Usage +===== + +1. In the target model's tree view, select the records to print. +2. Click *Action* and your label report action name. +3. Select the number of labels per record to print, and click Print. + +.. image:: https://raw.githubusercontent.com/OCA/reporting-engine/14.0/report_label/static/description/label_wizard.png + +Known issues / Roadmap +====================== + +Known issues: + +* `wkhtmltopdf` doesn't always respect dpi, and mm measures don't match. For + this matter, it's recommended to use this module along with + `report_wkhtmltopdf_param` and enable `--disable-smart-shrinking`. + +* This module depends on `base_automation` only because this module extends + `ir.actions.server` with a new kind of action, and `base.automation` inherits + from `ir.actions.server` by delegation in such a way that the modules cannot + be loaded in another order. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Iván Todorovich +* Moka Tourisme + +Contributors +~~~~~~~~~~~~ + +* Iván Todorovich +* `Moka Tourisme `_: + + * Grégory Schreiner + +* Sylvain LE GAL +* Stefan Rijnhart + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px + :target: https://github.com/ivantodorovich + :alt: ivantodorovich + +Current `maintainer `__: + +|maintainer-ivantodorovich| + +This module is part of the `OCA/reporting-engine `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/report_label/__init__.py b/report_label/__init__.py new file mode 100644 index 000000000..aee8895e7 --- /dev/null +++ b/report_label/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/report_label/__manifest__.py b/report_label/__manifest__.py new file mode 100644 index 000000000..2bc2229cc --- /dev/null +++ b/report_label/__manifest__.py @@ -0,0 +1,25 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Report Labels", + "version": "14.0.1.0.0", + "summary": "Print configurable self-adhesive labels reports", + "author": "Iván Todorovich, Moka Tourisme, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/reporting-engine", + "license": "AGPL-3", + "category": "Reporting", + "maintainers": ["ivantodorovich"], + "depends": [ + "base_automation", + ], + "data": [ + "security/ir.model.access.csv", + "data/paperformat_label.xml", + "views/ir_actions_server.xml", + "views/report_paperformat_label.xml", + "reports/report_label.xml", + "wizards/report_label_wizard.xml", + ], + "demo": [ + "demo/demo.xml", + ], +} diff --git a/report_label/data/paperformat_label.xml b/report_label/data/paperformat_label.xml new file mode 100644 index 000000000..7da0a7058 --- /dev/null +++ b/report_label/data/paperformat_label.xml @@ -0,0 +1,27 @@ + + + + + + Label: Agipa 114016 + A5 + Portrait + + + + + + + + + + + + + + + + + + + diff --git a/report_label/demo/demo.xml b/report_label/demo/demo.xml new file mode 100644 index 000000000..ea2263707 --- /dev/null +++ b/report_label/demo/demo.xml @@ -0,0 +1,43 @@ + + + + + + + Partner Label + A4 + + + + + + + + + + Print Address Labels + report_label + + + report_label.label_template_partner_address + + + + + + diff --git a/report_label/i18n/report_label.pot b/report_label/i18n/report_label.pot new file mode 100644 index 000000000..386bedeee --- /dev/null +++ b/report_label/i18n/report_label.pot @@ -0,0 +1,521 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * report_label +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_ir_actions_server__state +#: model:ir.model.fields,field_description:report_label.field_ir_cron__state +msgid "Action To Do" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Add Followers" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__report_ids +msgid "Associated reports" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Bottom (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__margin_bottom +msgid "Bottom Margin (mm)" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_wizard_view_form +msgid "Cancel" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Create Next Activity" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Create a new Record" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__create_uid +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__create_uid +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__create_uid +msgid "Created by" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__create_date +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__create_date +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__create_date +msgid "Created on" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__default +msgid "Default paper format ?" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__display_name +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__display_name +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__display_name +msgid "Display Name" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.view_server_action_form +msgid "Display a button in the sidebar of related model to open a wizard" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__header_line +msgid "Display a header line" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Execute Python Code" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Execute several actions" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,help:report_label.field_report_paperformat_label__report_ids +msgid "Explicitly associated reports" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__header_spacing +msgid "Header spacing" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__id +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__id +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__id +msgid "ID" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_height +msgid "Label Height (mm)" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Label Margin" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_margin_bottom +msgid "Label Margin Bottom (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_margin_left +msgid "Label Margin Left (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_margin_right +msgid "Label Margin Right (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_margin_top +msgid "Label Margin Top (mm)" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Label Padding" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_padding_bottom +msgid "Label Padding Bottom (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_padding_left +msgid "Label Padding Left (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_padding_right +msgid "Label Padding Right (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_padding_top +msgid "Label Padding Top (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model,name:report_label.model_report_paperformat_label +#: model:ir.model.fields,field_description:report_label.field_ir_actions_server__label_paperformat_id +#: model:ir.model.fields,field_description:report_label.field_ir_cron__label_paperformat_id +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__label_paperformat_id +msgid "Label Paper Format" +msgstr "" + +#. module: report_label +#: model:ir.ui.menu,name:report_label.paperformat_label_menu +msgid "Label Paper Formats" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_ir_actions_server__label_template +#: model:ir.model.fields,field_description:report_label.field_ir_cron__label_template +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__label_template +msgid "Label QWeb Template" +msgstr "" + +#. module: report_label +#: model:ir.actions.report,name:report_label.report_label +msgid "Label Report" +msgstr "" + +#. module: report_label +#: model:ir.actions.act_window,name:report_label.report_label_action +#: model:ir.ui.menu,name:report_label.report_label_menu +msgid "Label Reports" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Label Size" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__label_width +msgid "Label Width (mm)" +msgstr "" + +#. module: report_label +#: model:ir.actions.act_window,name:report_label.paperformat_label_action +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_tree +msgid "Label paper format configuration" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard____last_update +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line____last_update +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label____last_update +msgid "Last Modified on" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__write_uid +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__write_uid +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__write_date +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__write_date +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__write_date +msgid "Last Updated on" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Left (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__margin_left +msgid "Left Margin (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__line_ids +msgid "Lines" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__model_id +msgid "Model" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__name +msgid "Name" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,help:report_label.field_report_label_wizard__offset +msgid "Number of labels to skip when printing" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard__offset +msgid "Offset" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__orientation +msgid "Orientation" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__dpi +msgid "Output DPI" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__page_height +msgid "Page height (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__page_width +msgid "Page width (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__paperformat_id +msgid "Paper Format" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__format +msgid "Paper size" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_wizard_view_form +msgid "Print" +msgstr "" + +#. module: report_label +#: model:ir.actions.server,name:report_label.actions_server_label_partner_address +msgid "Print Address Labels" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_wizard_view_form +msgid "Print Labels" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__print_page_height +msgid "Print page height (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__print_page_width +msgid "Print page width (mm)" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Print self-adhesive labels" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__quantity +msgid "Quantity" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_wizard_view_form +msgid "Record" +msgstr "" + +#. module: report_label +#: model:ir.model,name:report_label.model_ir_actions_report +msgid "Report Action" +msgstr "" + +#. module: report_label +#: model:ir.model,name:report_label.model_report_label_wizard +msgid "Report Label Wizard" +msgstr "" + +#. module: report_label +#: model:ir.model,name:report_label.model_report_label_wizard_line +msgid "Report Label Wizard Line" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__res_name +msgid "Res Name" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__res_id +msgid "Resource ID" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Right (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__margin_right +msgid "Right Margin (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,help:report_label.field_report_paperformat_label__format +msgid "Select Proper Paper size" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Send Email" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__sequence +msgid "Sequence" +msgstr "" + +#. module: report_label +#: model:ir.model,name:report_label.model_ir_actions_server +msgid "Server Action" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_wizard_view_form +msgid "Settings" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,help:report_label.field_ir_actions_server__label_template +#: model:ir.model.fields,help:report_label.field_ir_cron__label_template +msgid "The QWeb template key to render the labels" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.paperformat_label_view_form +msgid "Top (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_paperformat_label__margin_top +msgid "Top Margin (mm)" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,help:report_label.field_ir_actions_server__state +#: model:ir.model.fields,help:report_label.field_ir_cron__state +msgid "Type of server action. The following values are available:\n" +"- 'Execute Python Code': a block of python code that will be executed\n" +"- 'Create': create a new record with new values\n" +"- 'Update a Record': update the values of a record\n" +"- 'Execute several actions': define an action that triggers several other server actions\n" +"- 'Send Email': automatically send an email (Discuss)\n" +"- 'Add Followers': add followers to a record (Discuss)\n" +"- 'Create Next Activity': create an activity (Discuss)" +msgstr "" + +#. module: report_label +#: selection:ir.actions.server,state:0 +msgid "Update the Record" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.view_server_action_form +msgid "View QWeb templates" +msgstr "" + +#. module: report_label +#: model:ir.model.fields,field_description:report_label.field_report_label_wizard_line__wizard_id +msgid "Wizard" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "height:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" display: inline-block;\n" +" overflow: hidden;\n" +" float: left;\n" +" position: relative;\n" +" page-break-inside: avoid;\n" +" box-sizing: border-box;" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" margin-bottom:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" margin-left:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" margin-right:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" margin-top:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" padding-bottom:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" padding-left:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" padding-right:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" padding-top:" +msgstr "" + +#. module: report_label +#: model_terms:ir.ui.view,arch_db:report_label.report_label_template +msgid "mm;\n" +" width:" +msgstr "" + diff --git a/report_label/models/__init__.py b/report_label/models/__init__.py new file mode 100644 index 000000000..2536ea822 --- /dev/null +++ b/report_label/models/__init__.py @@ -0,0 +1,3 @@ +from . import report_paperformat_label +from . import ir_actions_server +from . import ir_actions_report diff --git a/report_label/models/ir_actions_report.py b/report_label/models/ir_actions_report.py new file mode 100644 index 000000000..c4241de2e --- /dev/null +++ b/report_label/models/ir_actions_report.py @@ -0,0 +1,15 @@ +from odoo import api, models + + +class IrActionsReport(models.Model): + _inherit = "ir.actions.report" + + @api.model + def get_paperformat(self): + # Allow to define paperformat via context + res = super().get_paperformat() + if self.env.context.get("paperformat_id"): + res = self.env["report.paperformat"].browse( + self.env.context.get("paperformat_id") + ) + return res diff --git a/report_label/models/ir_actions_server.py b/report_label/models/ir_actions_server.py new file mode 100644 index 000000000..ff030fa98 --- /dev/null +++ b/report_label/models/ir_actions_server.py @@ -0,0 +1,55 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class IrActionsServer(models.Model): + _inherit = "ir.actions.server" + + state = fields.Selection( + selection_add=[("report_label", "Print self-adhesive labels")], + ondelete={"report_label": "cascade"}, + ) + label_template = fields.Char( + "Label QWeb Template", + help="The QWeb template key to render the labels", + states={"report_label": [("required", True)]}, + ) + label_paperformat_id = fields.Many2one( + "report.paperformat.label", + "Label Paper Format", + states={"report_label": [("required", True)]}, + ) + + def report_label_associated_view(self): + """View the associated qweb templates""" + self.ensure_one() + action = self.env.ref("base.action_ui_view", raise_if_not_found=False) + if not action or len(self.label_template.split(".")) < 2: + return False + res = action.read()[0] + res["domain"] = [ + ("type", "=", "qweb"), + "|", + ("name", "ilike", self.label_template.split(".")[1]), + ("key", "=", self.label_template), + ] + return res + + def _run_action_report_label_multi(self, eval_context=None): + """Show report label wizard""" + context = dict(self.env.context) + context.update( + { + "label_template": self.label_template, + "label_paperformat_id": self.label_paperformat_id.id, + "res_model_id": self.model_id.id, + } + ) + return { + "name": self.name, + "type": "ir.actions.act_window", + "res_model": "report.label.wizard", + "context": context, + "view_mode": "form", + "target": "new", + } diff --git a/report_label/models/report_paperformat_label.py b/report_label/models/report_paperformat_label.py new file mode 100644 index 000000000..7c2afb19a --- /dev/null +++ b/report_label/models/report_paperformat_label.py @@ -0,0 +1,38 @@ +from odoo import fields, models + + +class ReportPaperformatLabel(models.Model): + _name = "report.paperformat.label" + _inherits = {"report.paperformat": "paperformat_id"} + _description = "Label Paper Format" + + paperformat_id = fields.Many2one( + "report.paperformat", + string="Paper Format", + required=True, + ondelete="cascade", + ) + label_width = fields.Float( + "Label Width (mm)", + default=60, + required=True, + ) + label_height = fields.Float( + "Label Height (mm)", + default=42.3, + required=True, + ) + label_padding_top = fields.Float("Label Padding Top (mm)", default=2) + label_padding_right = fields.Float("Label Padding Right (mm)", default=2) + label_padding_bottom = fields.Float("Label Padding Bottom (mm)", default=2) + label_padding_left = fields.Float("Label Padding Left (mm)", default=2) + label_margin_top = fields.Float("Label Margin Top (mm)", default=2) + label_margin_right = fields.Float("Label Margin Right (mm)", default=2) + label_margin_bottom = fields.Float("Label Margin Bottom (mm)", default=2) + label_margin_left = fields.Float("Label Margin Left (mm)", default=2) + + # Overload inherits defaults + orientation = fields.Selection(inherited=True, default="Portrait") + header_spacing = fields.Integer(inherited=True, default=0) + margin_top = fields.Float(inherited=True, default=7) + margin_bottom = fields.Float(inherited=True, default=7) diff --git a/report_label/readme/CONFIGURE.rst b/report_label/readme/CONFIGURE.rst new file mode 100644 index 000000000..2d61181f4 --- /dev/null +++ b/report_label/readme/CONFIGURE.rst @@ -0,0 +1,10 @@ +Go to **Settings > Technical > Analysis > Label Paper Format** and create +your self-adhesive label paper formats. + +.. image:: ../static/description/configure_paperformat.png + +Go to **Settings > Technical > Analysis > Label Report** and create your label +report, and its context action. You'll also need to create or reuse a +QWeb template for you label. + +.. image:: ../static/description/configure_report_label.png diff --git a/report_label/readme/CONTRIBUTORS.rst b/report_label/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..efa1e4243 --- /dev/null +++ b/report_label/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* Iván Todorovich +* `Moka Tourisme `_: + + * Grégory Schreiner + +* Sylvain LE GAL +* Stefan Rijnhart diff --git a/report_label/readme/DESCRIPTION.rst b/report_label/readme/DESCRIPTION.rst new file mode 100644 index 000000000..7be00e255 --- /dev/null +++ b/report_label/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to create self-adhesive label printing actions on any model. diff --git a/report_label/readme/ROADMAP.rst b/report_label/readme/ROADMAP.rst new file mode 100644 index 000000000..893687abe --- /dev/null +++ b/report_label/readme/ROADMAP.rst @@ -0,0 +1,10 @@ +Known issues: + +* `wkhtmltopdf` doesn't always respect dpi, and mm measures don't match. For + this matter, it's recommended to use this module along with + `report_wkhtmltopdf_param` and enable `--disable-smart-shrinking`. + +* This module depends on `base_automation` only because this module extends + `ir.actions.server` with a new kind of action, and `base.automation` inherits + from `ir.actions.server` by delegation in such a way that the modules cannot + be loaded in another order. diff --git a/report_label/readme/USAGE.rst b/report_label/readme/USAGE.rst new file mode 100644 index 000000000..72b0c113a --- /dev/null +++ b/report_label/readme/USAGE.rst @@ -0,0 +1,5 @@ +1. In the target model's tree view, select the records to print. +2. Click *Action* and your label report action name. +3. Select the number of labels per record to print, and click Print. + +.. image:: ../static/description/label_wizard.png diff --git a/report_label/reports/report_label.xml b/report_label/reports/report_label.xml new file mode 100644 index 000000000..5c62bdb79 --- /dev/null +++ b/report_label/reports/report_label.xml @@ -0,0 +1,52 @@ + + + + + + + Label Report + report.label.wizard + qweb-pdf + report_label.report_label_template + report_label.report_label_template + + + diff --git a/report_label/security/ir.model.access.csv b/report_label/security/ir.model.access.csv new file mode 100644 index 000000000..d63204cff --- /dev/null +++ b/report_label/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_report_paperformat_label_all,report.paperformat.label all,model_report_paperformat_label,base.group_user,1,0,0,0 +access_report_label_layout_admin,report.paperformat.label admin,model_report_paperformat_label,base.group_system,1,1,1,1 +access_report_label_wizard,report.label.wizard,model_report_label_wizard,base.group_user,1,1,1,1 +access_report_label_wizard_line,report.label.wizard.line,model_report_label_wizard_line,base.group_user,1,1,1,1 diff --git a/report_label/static/description/configure_paperformat.png b/report_label/static/description/configure_paperformat.png new file mode 100644 index 000000000..cf91c5f64 Binary files /dev/null and b/report_label/static/description/configure_paperformat.png differ diff --git a/report_label/static/description/configure_report_label.png b/report_label/static/description/configure_report_label.png new file mode 100644 index 000000000..0d52c6717 Binary files /dev/null and b/report_label/static/description/configure_report_label.png differ diff --git a/report_label/static/description/icon.png b/report_label/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/report_label/static/description/icon.png differ diff --git a/report_label/static/description/index.html b/report_label/static/description/index.html new file mode 100644 index 000000000..bd7027f33 --- /dev/null +++ b/report_label/static/description/index.html @@ -0,0 +1,469 @@ + + + + + + +Report Labels + + + +
+

Report Labels

+ + +

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runbot

+

This module allows you to create self-adhesive label printing actions on any model.

+

Table of contents

+ +
+

Configuration

+

Go to Settings > Technical > Analysis > Label Paper Format and create +your self-adhesive label paper formats.

+https://raw.githubusercontent.com/OCA/reporting-engine/14.0/report_label/static/description/configure_paperformat.png +

Go to Settings > Technical > Analysis > Label Report and create your label +report, and its context action. You’ll also need to create or reuse a +QWeb template for you label.

+https://raw.githubusercontent.com/OCA/reporting-engine/14.0/report_label/static/description/configure_report_label.png +
+
+

Usage

+
    +
  1. In the target model’s tree view, select the records to print.
  2. +
  3. Click Action and your label report action name.
  4. +
  5. Select the number of labels per record to print, and click Print.
  6. +
+https://raw.githubusercontent.com/OCA/reporting-engine/14.0/report_label/static/description/label_wizard.png +
+
+

Known issues / Roadmap

+

Known issues:

+
    +
  • wkhtmltopdf doesn’t always respect dpi, and mm measures don’t match. For +this matter, it’s recommended to use this module along with +report_wkhtmltopdf_param and enable –disable-smart-shrinking.
  • +
  • This module depends on base_automation only because this module extends +ir.actions.server with a new kind of action, and base.automation inherits +from ir.actions.server by delegation in such a way that the modules cannot +be loaded in another order.
  • +
+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Iván Todorovich
  • +
  • Moka Tourisme
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

ivantodorovich

+

This module is part of the OCA/reporting-engine project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/report_label/static/description/label_wizard.png b/report_label/static/description/label_wizard.png new file mode 100644 index 000000000..201988132 Binary files /dev/null and b/report_label/static/description/label_wizard.png differ diff --git a/report_label/tests/__init__.py b/report_label/tests/__init__.py new file mode 100644 index 000000000..255f7911a --- /dev/null +++ b/report_label/tests/__init__.py @@ -0,0 +1 @@ +from . import test_report_label diff --git a/report_label/tests/test_report_label.py b/report_label/tests/test_report_label.py new file mode 100644 index 000000000..be63179a7 --- /dev/null +++ b/report_label/tests/test_report_label.py @@ -0,0 +1,27 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common + + +class TestReportLabel(common.TransactionCase): + def setUp(self): + super().setUp() + self.partner_label = self.env.ref( + "report_label.actions_server_label_partner_address" + ) + + def test_01_print_partner_label(self): + self.partner_label.create_action() + action = self.partner_label.run() + model = action["res_model"] + context = action["context"] + context.update( + { + "active_model": "res.partner", + "active_ids": self.env["res.partner"].search([]).ids, + "discard_logo_check": True, + } + ) + wizard = self.env[model].with_context(context).create({}) + report_action = wizard.print_report() + self.assertEquals(report_action["type"], "ir.actions.report") diff --git a/report_label/views/ir_actions_server.xml b/report_label/views/ir_actions_server.xml new file mode 100644 index 000000000..6bb1bc5ca --- /dev/null +++ b/report_label/views/ir_actions_server.xml @@ -0,0 +1,46 @@ + + + + + ir.actions.server + + +
+
+ + + + + +
+ + + Label Reports + ir.actions.server + tree,form + [("state", "=", "report_label")] + {"default_state": "report_label"} + + + + +
diff --git a/report_label/views/report_paperformat_label.xml b/report_label/views/report_paperformat_label.xml new file mode 100644 index 000000000..e31d4391c --- /dev/null +++ b/report_label/views/report_paperformat_label.xml @@ -0,0 +1,70 @@ + + + + + report.paperformat.label + + primary + + + + 1 + + + 1 + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + report.paperformat.label + + + + + + + + + + + Label paper format configuration + report.paperformat.label + tree,form + [] + {} + + + + + diff --git a/report_label/wizards/__init__.py b/report_label/wizards/__init__.py new file mode 100644 index 000000000..c7b605c91 --- /dev/null +++ b/report_label/wizards/__init__.py @@ -0,0 +1 @@ +from . import report_label_wizard diff --git a/report_label/wizards/report_label_wizard.py b/report_label/wizards/report_label_wizard.py new file mode 100644 index 000000000..9e4a371c3 --- /dev/null +++ b/report_label/wizards/report_label_wizard.py @@ -0,0 +1,108 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class ReportLabelWizard(models.TransientModel): + _name = "report.label.wizard" + _description = "Report Label Wizard" + + @api.model + def _default_line_ids(self): + """Compute line_ids based on context""" + active_model = self.env.context.get("active_model") + active_ids = self.env.context.get("active_ids", []) + if not active_model or not active_ids: + return False + return [ + ( + 0, + 0, + { + "res_id": res_id, + "quantity": 1, + }, + ) + for res_id in active_ids + ] + + model_id = fields.Many2one( + "ir.model", + "Model", + required=True, + default=lambda self: self.env.context.get("res_model_id"), + ) + label_paperformat_id = fields.Many2one( + "report.paperformat.label", + "Label Paper Format", + readonly=True, + required=True, + default=lambda self: self.env.context.get("label_paperformat_id"), + ) + label_template = fields.Char( + "Label QWeb Template", + readonly=True, + required=True, + default=lambda self: self.env.context.get("label_template"), + ) + offset = fields.Integer( + help="Number of labels to skip when printing", + ) + line_ids = fields.One2many( + "report.label.wizard.line", + "wizard_id", + "Lines", + default=_default_line_ids, + required=True, + ) + + def _prepare_report_data(self): + self.ensure_one() + return { + "label_format": self.label_paperformat_id.read()[0], + "label_template": self.label_template, + "offset": self.offset, + "res_model": self.model_id.model, + "lines": [ + { + "res_id": line.res_id, + "quantity": line.quantity, + } + for line in self.line_ids + ], + } + + def print_report(self): + self.ensure_one() + report = self.env.ref("report_label.report_label") + action = report.report_action(self, data=self._prepare_report_data()) + action["context"] = { + "paperformat_id": self.label_paperformat_id.paperformat_id.id, + } + return action + + +class ReportLabelWizardLine(models.TransientModel): + _name = "report.label.wizard.line" + _description = "Report Label Wizard Line" + _order = "sequence" + + wizard_id = fields.Many2one( + "report.label.wizard", + "Wizard", + required=True, + ondelete="cascade", + ) + sequence = fields.Integer(default=10) + res_id = fields.Integer("Resource ID", required=True) + res_name = fields.Char(compute="_compute_res_name") + quantity = fields.Integer(default=1, required=True) + + @api.depends("wizard_id.model_id", "res_id") + def _compute_res_name(self): + wizard = self.mapped("wizard_id") + wizard.ensure_one() + res_model = wizard.model_id.model + res_ids = self.mapped("res_id") + names_map = dict(self.env[res_model].browse(res_ids).name_get()) + for rec in self: + rec.res_name = names_map.get(rec.res_id) diff --git a/report_label/wizards/report_label_wizard.xml b/report_label/wizards/report_label_wizard.xml new file mode 100644 index 000000000..c6db5895b --- /dev/null +++ b/report_label/wizards/report_label_wizard.xml @@ -0,0 +1,42 @@ + + + + + report.label.wizard + +
+ + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
diff --git a/report_py3o/controllers/main.py b/report_py3o/controllers/main.py index c26fee9fb..fcc81b5d1 100644 --- a/report_py3o/controllers/main.py +++ b/report_py3o/controllers/main.py @@ -57,7 +57,7 @@ class ReportController(main.ReportController): return request.make_response(res, headers=http_headers) @route() - def report_download(self, data, token): + def report_download(self, data, token, context=None): """This function is used by 'qwebactionmanager.js' in order to trigger the download of a py3o/controller report. @@ -68,7 +68,9 @@ class ReportController(main.ReportController): requestcontent = json.loads(data) url, report_type = requestcontent[0], requestcontent[1] if "py3o" not in report_type: - return super(ReportController, self).report_download(data, token) + return super(ReportController, self).report_download( + data, token, context=context + ) try: reportname = url.split("/report/py3o/")[1].split("?")[0] docids = None diff --git a/report_qweb_encrypt/controllers/main.py b/report_qweb_encrypt/controllers/main.py index 015468354..ed8526f18 100644 --- a/report_qweb_encrypt/controllers/main.py +++ b/report_qweb_encrypt/controllers/main.py @@ -12,8 +12,8 @@ from odoo.addons.web.controllers import main as report class ReportController(report.ReportController): @route() - def report_download(self, data, token): - result = super().report_download(data, token) + def report_download(self, data, token, context=None): + result = super().report_download(data, token, context=context) # When report is downloaded from print action, this function is called, # but this function cannot pass context (manually entered password) to # report.render_qweb_pdf(), encrypton for manual password is done here. diff --git a/report_qweb_encrypt/models/ir_actions_report.py b/report_qweb_encrypt/models/ir_actions_report.py index 6f4be9bf6..2a15da2f4 100644 --- a/report_qweb_encrypt/models/ir_actions_report.py +++ b/report_qweb_encrypt/models/ir_actions_report.py @@ -34,10 +34,11 @@ class IrActionsReport(models.Model): document, ttype = super(IrActionsReport, self)._render_qweb_pdf( res_ids=res_ids, data=data ) - if isinstance(res_ids, int): - res_ids = [res_ids] - password = self._get_pdf_password(res_ids[:1]) - document = self._encrypt_pdf(document, password) + if res_ids: + if isinstance(res_ids, int): + res_ids = [res_ids] + password = self._get_pdf_password(res_ids[:1]) + document = self._encrypt_pdf(document, password) return document, ttype def _get_pdf_password(self, res_id): diff --git a/setup/report_label/odoo/addons/report_label b/setup/report_label/odoo/addons/report_label new file mode 120000 index 000000000..c0b27f2f7 --- /dev/null +++ b/setup/report_label/odoo/addons/report_label @@ -0,0 +1 @@ +../../../../report_label \ No newline at end of file diff --git a/setup/report_label/setup.py b/setup/report_label/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/report_label/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)