forked from OCA/reporting-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/15.0/batch report printing #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ambientstl
wants to merge
8
commits into
15.0
Choose a base branch
from
feature/15.0/batch_report_printing
base: 15.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b988fb6
[11.0][ADD] Batch report printing
f94160e
[IMP] report_batch: black, isort, prettier
f0e6043
[13.0][MIG] report_batch
5074467
[IMP] report_batch: black, isort, prettier
ambientstl 2954861
[MIG] report_batch: Migration to 14.0
ambientstl de322e5
[IMP] report_batch: black, isort, prettier
ambientstl c092714
[MIG] report_batch: Migration to 15.0
ambientstl 16ec888
[BLUE-3][UPD] Batch report printing customizations
ambientstl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| ===================== | ||
| Batch Report Printing | ||
| ===================== | ||
|
|
||
| .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! 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/13.0/report_batch | ||
| :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-13-0/reporting-engine-13-0-report_batch | ||
| :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/13.0 | ||
| :alt: Try me on Runbot | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module will allow to to print multiple QWeb reports in a single batch. | ||
| For example, picking, packing, reports needs to be printed together | ||
| in a single batch. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Configuration | ||
| ============= | ||
|
|
||
| We can configure this module in following two ways: | ||
|
|
||
| 1st Way | ||
| ======= | ||
|
|
||
| * Create a Report or edit existing report from Settings > Users & Companies > | ||
| Batch Reports | ||
| * Add sequence number and select parent report or design your own batch report. | ||
| * Select subreport to add reports and save it. | ||
|
|
||
| 2st Way | ||
| ======= | ||
|
|
||
| * Active developer mode. Go to Settings > Technical > Actions > Reports. | ||
| * Create or edit report and select related model. | ||
| * Jump on "Batch report" tab and add subreport one by one. | ||
| * Drag up and down and arrange a sequence of report. Save it. | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| If we configure it like following values: | ||
|
|
||
| * Name = Picking Batch Report | ||
| * Model = Transfer | ||
| * Template Name = my.picking_batch_report | ||
| * Add subreport = Delivery Slip and Picking Operations | ||
| * Save it. | ||
|
|
||
| To get results: | ||
|
|
||
| * Go to Inventory > Operations > Transfers | ||
| * Open one record or select multi records. | ||
| * Click on "Print" option near by "Action". | ||
| * Print "Picking Batch Report" | ||
| * We will get delivery slip and picking operations report together. | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/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 <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_batch%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ~~~~~~~ | ||
|
|
||
| * Open Source Integrators | ||
|
|
||
| Contributors | ||
| ~~~~~~~~~~~~ | ||
|
|
||
| * Bhavesh Odedra <bodedra@opensourceintegrators.com> | ||
| * Balaji Kannan <bkannan@opensourceintegrators.com> | ||
| * Daniel Reis <dreis@opensourceintegrators.com> | ||
|
|
||
| Other credits | ||
| ~~~~~~~~~~~~~ | ||
|
|
||
| The development of this module has been financially supported by: | ||
|
|
||
| * Open Source Integrators | ||
|
|
||
| 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-bodedra| image:: https://github.com/bodedra.png?size=40px | ||
| :target: https://github.com/bodedra | ||
| :alt: bodedra | ||
|
|
||
| Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-bodedra| | ||
|
|
||
| This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/13.0/report_batch>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright (C) 2019 IBM Corp. | ||
| # Copyright (C) 2019 Open Source Integrators | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Copyright (C) 2019 IBM Corp. | ||
| # Copyright (C) 2019 Open Source Integrators | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| { | ||
| "name": "Batch Report Printing", | ||
| "summary": "Ability to print multiple QWeb reports in a single batch.", | ||
| "version": "15.0.1.0.0", | ||
| "license": "AGPL-3", | ||
| "author": "Open Source Integrators, Odoo Community Association (OCA)", | ||
| "category": "Reporting", | ||
| "website": "https://github.com/OCA/reporting-engine", | ||
| "depends": ["sale", "stock"], | ||
| "data": [ | ||
| "security/ir.model.access.csv", | ||
| "views/form_batch_print_report_wizard.xml", | ||
| "views/ir_action_report_view.xml", | ||
| "views/report_batch_template.xml", | ||
| "views/action_batch_print_report.xml", | ||
| ], | ||
| "installable": True, | ||
| "maintainers": ["bodedra"], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_batch | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 13.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_batch | ||
| #: model_terms:ir.actions.act_window,help:report_batch.action_ir_actions_subreport | ||
| msgid "Allows to add multi QWeb reports in a single batch" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model_terms:ir.ui.view,arch_db:report_batch.act_batch_report_xml_view | ||
| msgid "Batch Report" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.actions.act_window,name:report_batch.action_ir_actions_subreport | ||
| #: model:ir.ui.menu,name:report_batch.menu_action_ir_actions_subreport | ||
| #: model_terms:ir.ui.view,arch_db:report_batch.act_batch_report_xml_view | ||
| #: model_terms:ir.ui.view,arch_db:report_batch.view_ir_actions_subreport_tree | ||
| msgid "Batch Reports" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__create_uid | ||
| msgid "Created by" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__create_date | ||
| msgid "Created on" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__display_name | ||
| msgid "Display Name" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__id | ||
| msgid "ID" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport____last_update | ||
| msgid "Last Modified on" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__write_uid | ||
| msgid "Last Updated by" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__write_date | ||
| msgid "Last Updated on" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__model | ||
| msgid "Model Name" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__parent_report_id | ||
| msgid "Parent Report" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model,name:report_batch.model_ir_actions_report | ||
| msgid "Report Action" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model,name:report_batch.model_ir_actions_report_subreport | ||
| msgid "Report Subreport" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__sequence | ||
| msgid "Sequence" | ||
| msgstr "" | ||
|
|
||
| #. module: report_batch | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report__subreport_ids | ||
| #: model:ir.model.fields,field_description:report_batch.field_ir_actions_report_subreport__subreport_id | ||
| msgid "Subreport" | ||
| msgstr "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Copyright (C) 2019 IBM Corp. | ||
| # Copyright (C) 2019 Open Source Integrators | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from . import batch_print_reports_wizard | ||
| from . import ir_action_report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import random | ||
| from odoo import _, api, fields, models | ||
| from odoo.tests.common import Form | ||
|
|
||
|
|
||
| class BatchPrintReportsWizard(models.TransientModel): | ||
| _name = "batch.print.reports.wizard" | ||
| _description = "Batch Print Reports Wizard" | ||
|
|
||
|
|
||
| is_collated_by_record = fields.Boolean(string="Collate reports by record?", default=True) | ||
| model_name = fields.Char(string="Model Name") | ||
| res_model = fields.Char(string="Model") | ||
| res_ids = fields.Char(string="Record IDs") | ||
|
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some |
||
| report_ids = fields.Many2many( | ||
| "ir.actions.report", | ||
| string="Reports", | ||
| domain="[('model', '=', res_model), ('report_type', '=', 'qweb-html'), ('binding_type', '=', 'report'), ('subreport_ids', '=', False)]" | ||
| ) | ||
|
|
||
| def generate_batch_report(self) -> dict: | ||
| """ | ||
| Create a batch report for the selected reports and generate the batch | ||
| report for the selected records. | ||
|
|
||
| :return: | ||
| A dictionary representation of a report action which loads the batch | ||
| report. | ||
| """ | ||
| self.ensure_one() | ||
|
|
||
| # Create a new report template by copying the generic report template | ||
| generic_template_id = self.env.ref("report_batch.generic_report_batch_template") | ||
| template_id = generic_template_id.copy({ | ||
| "name": "{}_parent_report_template_{}".format(self.res_model.replace(".", "_"), random.randint(0, 99999)), | ||
| "type": "qweb", | ||
| "model": self.res_model, | ||
| "mode": "primary", | ||
| "arch_base": generic_template_id.arch_base, | ||
| }) | ||
|
Comment on lines
+34
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be destroyed after we're done with it? |
||
|
|
||
| # Create a Parent Report | ||
| report_name = "{} Batch Reports".format(self.model_name) | ||
| parent_report_id = self.env["ir.actions.report"].create({ | ||
| "name": report_name, | ||
| "report_type": "qweb-html", | ||
| "model": self.res_model, | ||
| "report_name": template_id.name, | ||
| "print_report_name": report_name, | ||
| }) | ||
|
|
||
| # Create Sub-reports for each selected Report | ||
| subreport_obj = self.env["ir.actions.report.subreport"] | ||
|
|
||
| for count, report_id in enumerate(self.report_ids, start=1): | ||
| subreport_obj.create( | ||
| {"parent_report_id": parent_report_id.id, "sequence": 10 * count, "subreport_id": report_id.id} | ||
| ) | ||
|
|
||
| # Generate Qweb architecture for the batched report | ||
| parent_report_id._generate_batch_qweb_report(True, self.is_collated_by_record) | ||
|
|
||
| # Remove the batched report from the "Print" dropdown | ||
| parent_report_id.unlink_action() | ||
|
|
||
| # Get records | ||
| res_ids = self.env[self.res_model].search([("id", "in", list(map(int, self.res_ids.split(","))))]) | ||
|
|
||
| return parent_report_id.report_action(res_ids.ids) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.