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
17 changes: 17 additions & 0 deletions report_batch/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": "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": ["stock"],
"data": ["security/ir.model.access.csv", "views/ir_action_report_view.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 ""
5 changes: 5 additions & 0 deletions report_batch/models/__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 ir_action_report
108 changes: 108 additions & 0 deletions report_batch/models/ir_action_report.py
Original file line number Diff line number Diff line change
@@ -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 (
"""<?xml version="1.0"?>\n\t<t t-name="%s">\n\t
"""
% self.report_name
)

def generate_bottom_part(self):
return """\n
\t\t</t>\n\t\t"""

def generate_custom_content(self, report_name):
return (
"""\n
\t<t t-call="%s"/>"""
% 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
17 changes: 17 additions & 0 deletions report_batch/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions report_batch/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Balaji Kannan <bkannan@opensourceintegrators.com>
* Daniel Reis <dreis@opensourceintegrators.com>
3 changes: 3 additions & 0 deletions report_batch/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

* Open Source Integrators
Loading