-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][MIG] report_aeroo_replace_qweb (#68)
Co-authored-by: Majda EL MARIOULI <[email protected]>
- Loading branch information
Showing
20 changed files
with
332 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,43 @@ | ||
========================= | ||
Report Aeroo Replace Qweb | ||
========================= | ||
|
||
.. contents:: Table of Contents | ||
|
||
Context | ||
------- | ||
Most Odoo applications come with a predefined set of Qweb reports. | ||
|
||
These reports are linked to 'PRINT' action buttons in form views and portal pages. | ||
|
||
.. image:: static/description/sale_order_print_button_before.png | ||
|
||
.. image:: static/description/sale_order_report_downloaded_before.png | ||
|
||
Summary | ||
------- | ||
This module allows to replace an existing Qweb report with an Aeroo report. | ||
|
||
Usage | ||
----- | ||
To do so, go to the form view of your aeroo report. | ||
|
||
Inside the Qweb tab, select the report to replace. | ||
|
||
.. image:: static/description/aeroo_report_qweb_tab.png | ||
|
||
Now, when printing the original report, the new aeroo report is printed instead. | ||
|
||
.. image:: static/description/sale_order_print_button_after.png | ||
|
||
.. image:: static/description/sale_order_report_downloaded_after.png | ||
|
||
Do not forget to add your aeroo report to the related email templates. | ||
|
||
.. image:: static/description/sale_order_email_template.png | ||
|
||
.. image:: static/description/sale_order_email_template_2.png | ||
|
||
More information | ||
---------------- | ||
* Meet us at https://bit.ly/numigi-com |
This file contains 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,4 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import controllers, models |
This file contains 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,18 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Aeroo Reports Replace Qweb", | ||
"version": "16.0.1.0.0", | ||
"category": "Generic Modules/Aeroo Reports", | ||
"summary": "Replace an aeroo report with a Qweb report", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"depends": ["report_aeroo"], | ||
"data": [ | ||
"views/ir_actions_report.xml", | ||
], | ||
"license": "LGPL-3", | ||
"installable": True, | ||
} |
This file contains 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 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import main | ||
from . import portal |
This file contains 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,71 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
import json | ||
from odoo import http, models | ||
from odoo.http import request | ||
from odoo.addons.web.controllers.main import ReportController | ||
from typing import List | ||
|
||
|
||
class ReportControllerWithAerooReplacement(ReportController): | ||
|
||
@http.route(["/report/download"], type="http", auth="user") | ||
def report_download(self, data, token): | ||
"""Dowload a replacement aeroo report instead of a qweb report. | ||
If the report is qweb-pdf and it has a replacement aeroo report, | ||
the request is redirected to /web/report_aeroo. | ||
Without inheriting this method, the replacement report is printed, | ||
but with the filename defined on the qweb report. | ||
""" | ||
requestcontent = json.loads(data) | ||
url, type_ = requestcontent[0], requestcontent[1] | ||
|
||
if type_ == "qweb-pdf": | ||
report = _get_report_from_qweb_download_url(url) | ||
aeroo_report = report.aeroo_report_id | ||
|
||
if aeroo_report: | ||
record_ids = _get_doc_ids_from_qweb_download_url(url) | ||
return http.local_redirect( | ||
"/web/report_aeroo", | ||
{ | ||
"report_id": aeroo_report.id, | ||
"record_ids": json.dumps(record_ids), | ||
"token": token, | ||
}, | ||
) | ||
|
||
return super().report_download(data, token) | ||
|
||
|
||
def _get_report_from_qweb_download_url(url_: str) -> models.Model: | ||
"""Get the report object from the download URL of a qweb report. | ||
The url is expected to have the following format: | ||
/report/download/report_name/doc_ids?query_string | ||
""" | ||
report_name = url_.split("/")[3] | ||
return request.env["ir.actions.report"]._get_report_from_name(report_name) | ||
|
||
|
||
def _get_doc_ids_from_qweb_download_url(url_: str) -> List[int]: | ||
"""Get the report object from the download URL of a qweb report. | ||
The url is expected to have the following format: | ||
/report/download/report_name/doc_ids?query_string | ||
The parameter doc_ids inside the URL contains the ids of the | ||
objects seperated by commas. | ||
""" | ||
url_parts = url_.split("/") | ||
|
||
if len(url_parts) < 5: | ||
return [] | ||
|
||
ids_string = url_parts[4] | ||
return [int(i) for i in ids_string.split(",")] |
This file contains 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 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/gpl). | ||
|
||
from odoo.addons.portal.controllers.portal import CustomerPortal | ||
from odoo.http import request | ||
|
||
|
||
class PortalAccountWithAerooInvoiceReport(CustomerPortal): | ||
|
||
def _show_report(self, model, report_type, report_ref, download=False): | ||
"""Dowload a replacement aeroo report instead of a qweb report. | ||
Without inheriting this method, the replacement report is printed, | ||
but with the filename defined on the qweb report. | ||
""" | ||
report = request.env.ref(report_ref) | ||
report_id = report.sudo().aeroo_report_id | ||
if report_type == "pdf" and report_id: | ||
return self._show_aeroo_report(model, report_id, download=download) | ||
else: | ||
return super()._show_report( | ||
model, report_type, report_ref, download=download | ||
) |
This file contains 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,76 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * report_aeroo_replace_qweb | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-11-06 14:07+0000\n" | ||
"PO-Revision-Date: 2024-11-06 14:07+0000\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_aeroo_replace_qweb | ||
#: model:ir.model.fields,field_description:report_aeroo_replace_qweb.field_ir_actions_report__aeroo_report_id | ||
msgid "Aeroo Report" | ||
msgstr "" | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model_terms:ir.ui.view,arch_db:report_aeroo_replace_qweb.act_report_xml_view1 | ||
msgid "For example, you may replace the standard Quotation / Order report." | ||
msgstr "" | ||
"Par exemple, vous pouvez remplacer le rapport Soumission / Commande de " | ||
"l'application Ventes." | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model_terms:ir.ui.view,arch_db:report_aeroo_replace_qweb.act_report_xml_view1 | ||
msgid "Qweb" | ||
msgstr "" | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model:ir.model.fields,field_description:report_aeroo_replace_qweb.field_ir_actions_report__qweb_report_ids | ||
msgid "Qweb Report" | ||
msgstr "Rapport Qweb" | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model:ir.model,name:report_aeroo_replace_qweb.model_ir_actions_report | ||
msgid "Report Action" | ||
msgstr "Signaler l'action" | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model:ir.model.fields,help:report_aeroo_replace_qweb.field_ir_actions_report__qweb_report_ids | ||
msgid "" | ||
"This field allows to select Qweb reports that should be replaced by this " | ||
"Aeroo report. Only qweb-pdf reports are supported." | ||
msgstr "" | ||
"Ce champ permet de sélectionner un(des) rapport(s) Qweb à remplacer par ce " | ||
"rapport Aeroo. Seuls les rapports qweb-pdf sont supportés." | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model:ir.model.fields,help:report_aeroo_replace_qweb.field_ir_actions_report__aeroo_report_id | ||
msgid "This field allows to select an Aeroo report that replaces this report." | ||
msgstr "" | ||
"Ce champ permet de sélectionner un rapport Aeroo qui remplace ce rapport." | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model_terms:ir.ui.view,arch_db:report_aeroo_replace_qweb.act_report_xml_view1 | ||
msgid "" | ||
"This tab allows to select Qweb reports that should be replaced by this Aeroo" | ||
" report." | ||
msgstr "" | ||
"Cet onglet permet de sélectionner un(des) rapport Qweb à remplacer par ce " | ||
"rapport Aeroo." | ||
|
||
#. module: report_aeroo_replace_qweb | ||
#: model_terms:ir.ui.view,arch_db:report_aeroo_replace_qweb.act_report_xml_view1 | ||
msgid "" | ||
"When doing so, do not forget to adjust any related email template.\n" | ||
" See the documentation of Aeroo reports for more details." | ||
msgstr "" | ||
"Ce faisant, n'oubliez pas d'ajuster tout modèle d'e-mail associé.\n" | ||
" Consultez la documentation des rapports Aeroo pour plus de détails." |
This file contains 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,4 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import ir_actions_report |
This file contains 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,40 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class IrActionsReport(models.Model): | ||
"""Allow replacing a qweb report with an aeroo report. | ||
In the form view of a qweb report, a many2one field allows to select | ||
an aeroo report that replaces the qweb report. | ||
This allows to easily bind an aeroo report to the action buttons | ||
of a form view. By default, most of those buttons are bound to a qweb report. | ||
This feature supports the qweb-pdf format but not qweb-html. | ||
""" | ||
|
||
_inherit = "ir.actions.report" | ||
|
||
aeroo_report_id = fields.Many2one( | ||
"ir.actions.report", | ||
help="This field allows to select an Aeroo report that replaces this report.", | ||
) | ||
|
||
qweb_report_ids = fields.One2many( | ||
"ir.actions.report", | ||
"aeroo_report_id", | ||
help="This field allows to select Qweb reports that should be replaced " | ||
"by this Aeroo report. Only qweb-pdf reports are supported.", | ||
) | ||
|
||
def _render_qweb_pdf(self, report_ref, res_ids=None, data=None): | ||
report_sudo = self._get_report(report_ref) | ||
if report_sudo.aeroo_report_id: | ||
return report_sudo.aeroo_report_id._render_aeroo( | ||
doc_ids=res_ids, data=data, force_output_format="pdf" | ||
) | ||
|
||
return super()._render_qweb_pdf(report_ref, res_ids, data) |
Binary file added
BIN
+102 KB
report_aeroo_replace_qweb/static/description/aeroo_report_qweb_tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+116 KB
report_aeroo_replace_qweb/static/description/sale_order_email_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+111 KB
report_aeroo_replace_qweb/static/description/sale_order_email_template_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+97.7 KB
report_aeroo_replace_qweb/static/description/sale_order_print_button_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+97.7 KB
report_aeroo_replace_qweb/static/description/sale_order_print_button_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+75.8 KB
...rt_aeroo_replace_qweb/static/description/sale_order_report_downloaded_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.7 KB
...t_aeroo_replace_qweb/static/description/sale_order_report_downloaded_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="act_report_xml_view1" model="ir.ui.view"> | ||
<field name="name">Aeroo Report Form: add Qweb tab</field> | ||
<field name="model">ir.actions.report</field> | ||
<field name="inherit_id" ref="report_aeroo.act_report_xml_view1" /> | ||
<field name="arch" type="xml"> | ||
<notebook position="inside"> | ||
<page string="Qweb"> | ||
<div> | ||
<p> | ||
This tab allows to select Qweb reports that should be replaced by this Aeroo report. | ||
</p> | ||
<p> | ||
For example, you may replace the standard Quotation / Order report. | ||
</p> | ||
<p> | ||
When doing so, do not forget to adjust any related email template. | ||
See the documentation of Aeroo reports for more details. | ||
</p> | ||
</div> | ||
<field name="qweb_report_ids" | ||
domain="[('model', '=', model), ('report_type', '=', 'qweb-pdf')]" | ||
widget="many2many" | ||
/> | ||
</page> | ||
</notebook> | ||
</field> | ||
</record> | ||
|
||
<record id="qweb_report_form_with_aeroo_replacement" model="ir.ui.view"> | ||
<field name="name">Qweb Reports: add replacement Aeroo report</field> | ||
<field name="model">ir.actions.report</field> | ||
<field name="inherit_id" ref="base.act_report_xml_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="paperformat_id" position="after"> | ||
<field name="aeroo_report_id" | ||
domain="[('model', '=', model), ('report_type', '=', 'aeroo')]" | ||
attrs="{'invisible': [('report_type', '!=', 'qweb-pdf')]}" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |