Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions report_batch/README.rst
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.
5 changes: 5 additions & 0 deletions report_batch/__init__.py
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
23 changes: 23 additions & 0 deletions report_batch/__manifest__.py
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"],
}
98 changes: 98 additions & 0 deletions report_batch/i18n/report_batch.pot
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 ""
6 changes: 6 additions & 0 deletions report_batch/models/__init__.py
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
69 changes: 69 additions & 0 deletions report_batch/models/batch_print_reports_wizard.py
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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some help strings on these would be helpful imo

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

Choose a reason for hiding this comment

The 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)
Loading