diff --git a/report_batch/README.rst b/report_batch/README.rst new file mode 100644 index 000000000..afb521322 --- /dev/null +++ b/report_batch/README.rst @@ -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/11.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-11-0/reporting-engine-11-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/11.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 `_. +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 +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Bhavesh Odedra +* Balaji Kannan +* Daniel Reis + +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 `__: + +|maintainer-bodedra| + +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_batch/__init__.py b/report_batch/__init__.py new file mode 100644 index 000000000..f1ef2417f --- /dev/null +++ b/report_batch/__init__.py @@ -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 diff --git a/report_batch/__manifest__.py b/report_batch/__manifest__.py new file mode 100644 index 000000000..dd191a7a9 --- /dev/null +++ b/report_batch/__manifest__.py @@ -0,0 +1,17 @@ +# 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": "13.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": ["stock"], + "data": ["security/ir.model.access.csv", "views/ir_action_report_view.xml"], + "installable": True, + "maintainers": ["bodedra"], +} diff --git a/report_batch/models/__init__.py b/report_batch/models/__init__.py new file mode 100644 index 000000000..95d1c5045 --- /dev/null +++ b/report_batch/models/__init__.py @@ -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 ir_action_report diff --git a/report_batch/models/ir_action_report.py b/report_batch/models/ir_action_report.py new file mode 100644 index 000000000..710f3e3ec --- /dev/null +++ b/report_batch/models/ir_action_report.py @@ -0,0 +1,108 @@ +# Copyright (C) 2019 IBM Corp. +# Copyright (C) 2019 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import random + +from odoo import api, fields, models + + +class IrActionsReportSubreport(models.Model): + _name = "ir.actions.report.subreport" + _description = "Report Subreport" + _order = "sequence" + + parent_report_id = fields.Many2one("ir.actions.report", ondelete="cascade") + sequence = fields.Integer(default=10) + model = fields.Char(related="parent_report_id.model") + subreport_id = fields.Many2one( + "ir.actions.report", string="Subreport", required=True + ) + + +class IrActionsReport(models.Model): + _inherit = "ir.actions.report" + + subreport_ids = fields.One2many("ir.actions.report.subreport", "parent_report_id") + + def generate_top_part(self): + return ( + """\n\t\n\t + """ + % self.report_name + ) + + def generate_bottom_part(self): + return """\n + \t\t\n\t\t""" + + def generate_custom_content(self, report_name): + return ( + """\n + \t""" + % report_name + ) + + def _generate_batch_qweb_report(self, update_batch_qweb=False): + report_name = self.report_name + if "." in report_name: + module = self.report_name.split(".")[0] + report_name = self.report_name.split(".")[1] + else: + # Generate random number to avoid IntegrityError + module = random.randint(1, 1000000) + self.report_name = "{}.{}".format(module, report_name) + if self.subreport_ids: + if update_batch_qweb: + report_name = self.report_name.split(".")[1] + # Delete old Qweb batch report + model_data = self.env["ir.model.data"].search( + [("res_id", "=", self.id)] + ) + model_data.unlink() + ui_view = self.env["ir.ui.view"].search([("name", "=", report_name)]) + ui_view.unlink() + template_header = self.generate_top_part() + template_footer = self.generate_bottom_part() + template_content = "" + + for subreport in self.subreport_ids: + template_content += self.generate_custom_content( + subreport.subreport_id.report_name + ) + data = "{}{}{}".format(template_header, template_content, template_footer) + ui_view = self.env["ir.ui.view"].create( + { + "name": report_name, + "type": "qweb", + "model": self.model, + "mode": "primary", + "arch_base": data, + } + ) + self.env["ir.model.data"].create( + { + "module": module, + "name": report_name, + "res_id": ui_view.id, + "model": "ir.ui.view", + } + ) + # Register batch report option + if not self.binding_model_id: + self.create_action() + return True + + @api.model + def create(self, vals): + res = super(IrActionsReport, self).create(vals) + for report in res: + report._generate_batch_qweb_report() + return res + + def write(self, vals): + res = super(IrActionsReport, self).write(vals) + if "subreport_ids" in vals or "model" in vals: + for report in self: + report._generate_batch_qweb_report(update_batch_qweb=True) + return res diff --git a/report_batch/readme/CONFIGURE.rst b/report_batch/readme/CONFIGURE.rst new file mode 100644 index 000000000..d936942ab --- /dev/null +++ b/report_batch/readme/CONFIGURE.rst @@ -0,0 +1,17 @@ +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. diff --git a/report_batch/readme/CONTRIBUTORS.rst b/report_batch/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..910e80b9a --- /dev/null +++ b/report_batch/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Bhavesh Odedra +* Balaji Kannan +* Daniel Reis diff --git a/report_batch/readme/CREDITS.rst b/report_batch/readme/CREDITS.rst new file mode 100644 index 000000000..8209266d9 --- /dev/null +++ b/report_batch/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Open Source Integrators diff --git a/report_batch/readme/DESCRIPTION.rst b/report_batch/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6010b45e6 --- /dev/null +++ b/report_batch/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +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. diff --git a/report_batch/readme/USAGE.rst b/report_batch/readme/USAGE.rst new file mode 100644 index 000000000..fbcd85bf1 --- /dev/null +++ b/report_batch/readme/USAGE.rst @@ -0,0 +1,15 @@ +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. diff --git a/report_batch/security/ir.model.access.csv b/report_batch/security/ir.model.access.csv new file mode 100644 index 000000000..59dcd473b --- /dev/null +++ b/report_batch/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_ir_actions_subreport_all,ir_actions_report_subreport,model_ir_actions_report_subreport,,1,0,0,0 +access_ir_actions_subreport_group_system,ir_actions_report_subreport_group_system,model_ir_actions_report_subreport,base.group_system,1,1,1,1 diff --git a/report_batch/static/description/icon.png b/report_batch/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/report_batch/static/description/icon.png differ diff --git a/report_batch/static/description/index.html b/report_batch/static/description/index.html new file mode 100644 index 000000000..6bb7e054f --- /dev/null +++ b/report_batch/static/description/index.html @@ -0,0 +1,456 @@ + + + + + + +Batch Report Printing + + + +
+

Batch Report Printing

+ + +

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

+

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

+ +
+

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. +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

+
    +
  • Open Source Integrators
  • +
+
+ +
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Open Source Integrators
  • +
+
+
+

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:

+

bodedra

+

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_batch/tests/__init__.py b/report_batch/tests/__init__.py new file mode 100644 index 000000000..b3bef7e31 --- /dev/null +++ b/report_batch/tests/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2020 IBM Corp. +# Copyright (C) 2020 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_report_batch diff --git a/report_batch/tests/test_report_batch.py b/report_batch/tests/test_report_batch.py new file mode 100644 index 000000000..ee9a9f437 --- /dev/null +++ b/report_batch/tests/test_report_batch.py @@ -0,0 +1,36 @@ +# Copyright (C) 2019 IBM Corp. +# Copyright (C) 2019 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import odoo.tests.common as test_common + + +class TestReportBatch(test_common.SingleTransactionCase): + def setUp(self): + super(TestReportBatch, self).setUp() + self.report_picking_operations = self.env.ref("stock.action_report_picking") + self.report_deliveryslip = self.env.ref("stock.report_deliveryslip") + + def test_report_batch(self): + report_batch = self.env["ir.actions.report"].create( + { + "name": "Batch Report", + "report_type": "qweb-pdf", + "model": "stock.picking", + "report_name": "my_custom_batch_report", + } + ) + report_batch.write( + { + "subreport_ids": [ + ( + 6, + 0, + [ + self.report_picking_operations.id, + self.report_deliveryslip.id, + ], + ) + ] + } + ) diff --git a/report_batch/views/ir_action_report_view.xml b/report_batch/views/ir_action_report_view.xml new file mode 100644 index 000000000..aedc27a02 --- /dev/null +++ b/report_batch/views/ir_action_report_view.xml @@ -0,0 +1,50 @@ + + + + ir.actions.batch.report.form + ir.actions.report + + + + + + + + + + + + + + + + + + + ir.actions.report.subreport.tree + ir.actions.report.subreport + + + + + + + + + + + Batch Reports + ir.actions.act_window + ir.actions.report.subreport + Allows to add multi QWeb reports in a single batch + + +