changes
This commit is contained in:
@@ -1,28 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
Odoo Proprietary License v1.0
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
This software and associated files (the "Software") may only be used (executed,
|
||||
modified, executed after modifications) if you have purchased a valid license
|
||||
from the authors, typically via Odoo Apps, or if you have received a written
|
||||
agreement from the authors of the Software (see the COPYRIGHT file).
|
||||
Copyright (C) 2024 Nexa Systems Inc
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
You may develop Odoo modules that use the Software as a library (typically
|
||||
by depending on it, importing it and using its resources), but without copying
|
||||
any source code or material from the Software. You may distribute those
|
||||
modules under the license of your choice, provided that this license is
|
||||
compatible with the terms of the Odoo Proprietary License (For example:
|
||||
LGPL, MIT, or proprietary licenses similar to this one).
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
It is forbidden to publish, distribute, sublicense, or sell copies of the Software
|
||||
or modified copies of the Software.
|
||||
|
||||
The above copyright notice and this permission notice must be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
For the full text of this license, see https://www.gnu.org/licenses/lgpl-3.0.html
|
||||
|
||||
@@ -1,63 +1,52 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
{
|
||||
"name": "Pdf Print Preview",
|
||||
"version": "19.0.1.0.0",
|
||||
"name": "Fusion PDF Preview",
|
||||
"version": "19.0.2.0.0",
|
||||
"depends": ["web"],
|
||||
"author": "itechgroup",
|
||||
"author": "Nexa Systems Inc",
|
||||
"category": "web",
|
||||
"website": "",
|
||||
"summary": """Preview and print PDF report in your browser | Pdf direct preview | Print without Download
|
||||
| Quick printer | Easily to print report | Without download PDF File | Preview without Download | Preview report
|
||||
| Preview pdf | Odoo direct print | pdf preview | report Preview | PDF Viewer | report Viewer | PDF
|
||||
""",
|
||||
"website": "https://www.nexasystemsinc.com",
|
||||
"summary": "Preview and print PDF reports directly in your browser without downloading",
|
||||
"description": """
|
||||
Preview,
|
||||
Preview PDF,
|
||||
Preview print PDF,
|
||||
Preview report,
|
||||
Report,
|
||||
Print,
|
||||
Pdf direct preview,
|
||||
PDF preview,
|
||||
Direct preview,
|
||||
Direct print,
|
||||
Print Without Download,
|
||||
Print without,
|
||||
Download,
|
||||
Without Download,
|
||||
Quick Printer,
|
||||
Printer,
|
||||
Quick Pdf,
|
||||
Pos report,
|
||||
Pos,
|
||||
Sale,
|
||||
Purchase,
|
||||
Stock,
|
||||
Print report,
|
||||
Easily to print report,
|
||||
Without download PDF File,
|
||||
Preview without Download
|
||||
Fusion PDF Preview - by Nexa Systems Inc
|
||||
|
||||
Preview and print PDF reports directly in your browser without downloading.
|
||||
|
||||
Key Features:
|
||||
- In-browser PDF preview dialog with full-screen support
|
||||
- One-click printing without file download
|
||||
- Download and open-in-new-tab buttons in the preview dialog
|
||||
- Batch document preview
|
||||
- Per-user configurable preview and print preferences
|
||||
- Company-level default settings with bulk apply to all users
|
||||
- Report-specific behavior: always preview, always download, or always auto-print
|
||||
- Keyboard shortcuts: F (fullscreen), Ctrl+P (print), Ctrl+D (download)
|
||||
- Print audit log tracking who previewed, printed, or downloaded reports
|
||||
- Automatic printing mode for streamlined workflows
|
||||
- Error-safe PDF rendering with friendly error display
|
||||
- Compatible with Odoo 19 Community and Enterprise
|
||||
""",
|
||||
"live_test_url": "https://www.itechgroup.info/demo-request?utm_source=odoo-apps&utm_medium=demo-request&utm_campaign=pdf-preview-17",
|
||||
"support": "support@itechgroup.info",
|
||||
'website': "https://www.itechgroup.info/",
|
||||
"support": "support@nexasystemsinc.com",
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"data/ir_config_parameter_data.xml",
|
||||
"views/res_users.xml",
|
||||
"views/res_config_settings_views.xml",
|
||||
"views/ir_actions_report_views.xml",
|
||||
"views/preview_log_views.xml",
|
||||
"report/ir_actions_report_templates.xml",
|
||||
"report/ir_actions_report.xml",
|
||||
],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"pdf_print_preview/static/src/js/pdf_preview.js",
|
||||
"pdf_print_preview/static/src/js/user_menu.js",
|
||||
"pdf_print_preview/static/src/xml/pdf_viewer_dialog.xml"
|
||||
"fusion_pdf_preview/static/src/js/pdf_preview.js",
|
||||
"fusion_pdf_preview/static/src/js/user_menu.js",
|
||||
"fusion_pdf_preview/static/src/xml/pdf_viewer_dialog.xml",
|
||||
],
|
||||
},
|
||||
"images": ["static/description/banner.png"],
|
||||
"installable": True,
|
||||
"application": True,
|
||||
"license": "OPL-1",
|
||||
"currency": "EUR",
|
||||
"price": 25.99
|
||||
"license": "LGPL-3",
|
||||
}
|
||||
|
||||
@@ -1,41 +1,74 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import werkzeug.exceptions
|
||||
import logging
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from odoo.tools.safe_eval import safe_eval, time
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class PrintPreviewController(http.Controller):
|
||||
|
||||
@http.route('/pdf_print_preview/get_report_name', type='json', auth='user')
|
||||
def get_report_name(self, report_name=False, data={}):
|
||||
class FusionPDFPreviewController(http.Controller):
|
||||
|
||||
@http.route('/fusion_pdf_preview/get_report_name', type='json', auth='user')
|
||||
def get_report_name(self, report_name=False, data=None):
|
||||
file_name = ''
|
||||
|
||||
if not report_name:
|
||||
raise werkzeug.exceptions.HTTPException(
|
||||
description="Cannot found report name in param")
|
||||
raise request.not_found(
|
||||
description="Cannot find report name in parameters")
|
||||
|
||||
report = request.env['ir.actions.report']._get_report_from_name(
|
||||
report_name)
|
||||
if not report:
|
||||
raise werkzeug.exceptions.HTTPException(
|
||||
description=f"Cannot found report with name ( {report_name} )")
|
||||
raise request.not_found(
|
||||
description=f"Cannot find report with name ({report_name})")
|
||||
|
||||
print_report_name = report.print_report_name
|
||||
data = json.loads(data)
|
||||
if data:
|
||||
data = json.loads(data)
|
||||
else:
|
||||
data = {}
|
||||
res_ids = data.get('active_ids', [])
|
||||
records = request.env[report.model].browse(res_ids)
|
||||
try:
|
||||
if print_report_name and not len(records) > 1:
|
||||
file_name = safe_eval(print_report_name, {
|
||||
'object': records, 'time': time})
|
||||
except:
|
||||
pass
|
||||
file_name = safe_eval(print_report_name, {
|
||||
'object': records, 'time': time})
|
||||
except Exception:
|
||||
_logger.warning(
|
||||
"Failed to evaluate print_report_name for report %s",
|
||||
report_name, exc_info=True)
|
||||
|
||||
return {
|
||||
'file_name': file_name,
|
||||
'wkhtmltopdf_state': request.env['ir.actions.report'].get_wkhtmltopdf_state(),
|
||||
'fusion_preview_mode': report.fusion_preview_mode or 'default',
|
||||
}
|
||||
|
||||
@http.route('/fusion_pdf_preview/log_action', type='json', auth='user')
|
||||
def log_action(self, report_name=False, action_type=False, record_ids=False, model_name=False):
|
||||
"""Create an audit log entry for PDF preview/print/download actions."""
|
||||
if not report_name or not action_type:
|
||||
return {'success': False}
|
||||
|
||||
report = request.env['ir.actions.report']._get_report_from_name(report_name)
|
||||
|
||||
vals = {
|
||||
'user_id': request.env.uid,
|
||||
'report_name': report.name if report else report_name,
|
||||
'report_id': report.id if report else False,
|
||||
'action_type': action_type,
|
||||
'record_ids': record_ids or '',
|
||||
'model_name': model_name or (report.model if report else ''),
|
||||
}
|
||||
|
||||
try:
|
||||
request.env['fusion.pdf.preview.log'].sudo().create(vals)
|
||||
except Exception:
|
||||
_logger.warning("Failed to create PDF preview log entry", exc_info=True)
|
||||
return {'success': False}
|
||||
|
||||
return {'success': True}
|
||||
|
||||
13
fusion_pdf_preview/data/ir_config_parameter_data.xml
Normal file
13
fusion_pdf_preview/data/ir_config_parameter_data.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="config_default_preview_print" model="ir.config_parameter">
|
||||
<field name="key">fusion_pdf_preview.default_preview_print</field>
|
||||
<field name="value">True</field>
|
||||
</record>
|
||||
<record id="config_default_automatic_printing" model="ir.config_parameter">
|
||||
<field name="key">fusion_pdf_preview.default_automatic_printing</field>
|
||||
<field name="value">False</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,13 +1,13 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * pdf_print_preview
|
||||
# * fusion_pdf_preview
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Project-Id-Version: Odoo Server 19.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-12 22:59+0000\n"
|
||||
"PO-Revision-Date: 2019-03-12 22:59+0000\n"
|
||||
"POT-Creation-Date: 2024-01-01 00:00+0000\n"
|
||||
"PO-Revision-Date: 2024-01-01 00:00+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -15,120 +15,75 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.model.fields,field_description:pdf_print_preview.field_res_users_automatic_printing
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.model.fields,field_description:fusion_pdf_preview.field_res_users_automatic_printing
|
||||
msgid "Automatic printing"
|
||||
msgstr "Impression automatique"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.ui.view,arch_db:pdf_print_preview.short_preview_print_from
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.ui.view,arch_db:fusion_pdf_preview.short_preview_print_form
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/xml/dialog.xml:22
|
||||
#, python-format
|
||||
msgid "Close"
|
||||
msgstr "Fermer"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.model,name:pdf_print_preview.model_ir_http
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.model,name:fusion_pdf_preview.model_ir_http
|
||||
msgid "HTTP routing"
|
||||
msgstr "HTTP routing"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:59
|
||||
#, python-format
|
||||
msgid "Please allow <b style='color: red;'>pop up</b> in your browser to <b>preview report</> in another tab."
|
||||
msgstr "Veuillez autoriser <b style='color: red;'>pop up</b>dans votre navigateur d'un aperçu du rapport dans un autre onglet."
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.ui.view,arch_db:fusion_pdf_preview.view_users_preview_print_form
|
||||
msgid "PDF Preview"
|
||||
msgstr "Aperçu PDF"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/dialog.js:27
|
||||
#: model:ir.ui.view,arch_db:pdf_print_preview.view_users_preview_print_form
|
||||
#, python-format
|
||||
msgid "Preview"
|
||||
msgstr "Aperçu"
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.actions.act_window,name:fusion_pdf_preview.action_short_preview_print
|
||||
msgid "PDF Preview Settings"
|
||||
msgstr "Paramètres d'aperçu PDF"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.actions.act_window,name:pdf_print_preview.action_short_preview_print
|
||||
msgid "Preview Print"
|
||||
msgstr "Aperçu avant impression"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.model.fields,field_description:pdf_print_preview.field_res_users_preview_print
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.model.fields,field_description:fusion_pdf_preview.field_res_users_preview_print
|
||||
msgid "Preview print"
|
||||
msgstr "Aperçu avant impression"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.ui.view,arch_db:pdf_print_preview.view_users_preview_print_form
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.ui.view,arch_db:fusion_pdf_preview.view_users_preview_print_form
|
||||
msgid "Refresh"
|
||||
msgstr "Rafraîchir"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:35
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:59
|
||||
#: model:ir.ui.view,arch_db:pdf_print_preview.view_users_preview_print_form
|
||||
#, python-format
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.ui.view,arch_db:fusion_pdf_preview.view_users_preview_print_form
|
||||
msgid "Report"
|
||||
msgstr "Report"
|
||||
msgstr "Rapport"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. module: fusion_pdf_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/xml/user_menu.xml:6
|
||||
#: code:addons/fusion_pdf_preview/static/src/js/user_menu.js:0
|
||||
#, python-format
|
||||
msgid "Report preview"
|
||||
msgstr "Aperçu du rapport"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.ui.view,arch_db:pdf_print_preview.short_preview_print_from
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.ui.view,arch_db:fusion_pdf_preview.short_preview_print_form
|
||||
msgid "Save"
|
||||
msgstr "Sauvegarder"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:14
|
||||
#, python-format
|
||||
msgid "Unable to find Wkhtmltopdf on this \n"
|
||||
"system. The report will be shown in html.<br><br><a href='http://wkhtmltopdf.org/' target='_blank'>\n"
|
||||
"wkhtmltopdf.org</a>"
|
||||
msgstr "Wkhtmltopdf n'a pas été trouvé sur ce système.\n"
|
||||
"Le rapport sera affiché en HTML.<br><br><a href=\"http://wkhtmltopdf.org/\" target=\"_blank\">\n"
|
||||
"wkhtmltopdf.org</a>"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#: model:ir.model,name:pdf_print_preview.model_res_users
|
||||
#: model:ir.ui.view,arch_db:pdf_print_preview.short_preview_print_from
|
||||
#. module: fusion_pdf_preview
|
||||
#: model:ir.model,name:fusion_pdf_preview.model_res_users
|
||||
#: model:ir.ui.view,arch_db:fusion_pdf_preview.short_preview_print_form
|
||||
msgid "Users"
|
||||
msgstr "Utilisateurs"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. module: fusion_pdf_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:15
|
||||
#: code:addons/fusion_pdf_preview/static/src/js/pdf_preview.js:0
|
||||
#, python-format
|
||||
msgid "You need to start OpenERP with at least two \n"
|
||||
"workers to print a pdf version of the reports."
|
||||
msgstr "Vous devez démarrer Odoo avec au moins 2 workers pour imprimer une version PDF des rapports."
|
||||
msgid "Failed to print automatically. Please check your browser settings."
|
||||
msgstr "L'impression automatique a échoué. Veuillez vérifier les paramètres de votre navigateur."
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. module: fusion_pdf_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:16
|
||||
#: code:addons/fusion_pdf_preview/static/src/js/pdf_preview.js:0
|
||||
#, python-format
|
||||
msgid "You should upgrade your version of\n"
|
||||
"Wkhtmltopdf to at least 0.12.0 in order to get a correct display of headers and footers as well as\n"
|
||||
"support for table-breaking between pages.<br><br><a href='http://wkhtmltopdf.org/' \n"
|
||||
"target='_blank'>wkhtmltopdf.org</a>"
|
||||
msgstr "Vous devriez mettre à jour la version de \n"
|
||||
"Wkhtmltopdf (0.12.0 min.) pour avoir un affichage correct des entêtes et des pieds de page\n"
|
||||
"ainsi que le support de la table des sauts de page <br><br><a href=\"http://wkhtmltopdf.org/\" target=\"_blank\">wkhtmltopdf.org</a>"
|
||||
|
||||
#. module: pdf_print_preview
|
||||
#. openerp-web
|
||||
#: code:addons/pdf_print_preview/static/src/js/pdf_preview.js:17
|
||||
#, python-format
|
||||
msgid "Your installation of Wkhtmltopdf seems to be broken. The report will be shown in html.<br><br><a href='http://wkhtmltopdf.org/' target='_blank'>wkhtmltopdf.org</a>"
|
||||
msgstr "Your installation of Wkhtmltopdf seems to be broken. The report will be shown in html.<br><br><a href='http://wkhtmltopdf.org/' target='_blank'>wkhtmltopdf.org</a>"
|
||||
msgid "Printing Error"
|
||||
msgstr "Erreur d'impression"
|
||||
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
from . import res_users
|
||||
from . import ir_http
|
||||
from . import ir_actions_report
|
||||
from . import res_config_settings
|
||||
from . import preview_log
|
||||
|
||||
@@ -1,28 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, tools
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
import traceback
|
||||
|
||||
from odoo import fields, models, tools
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
class Http(models.Model):
|
||||
|
||||
class IrActionsReport(models.Model):
|
||||
_inherit = "ir.actions.report"
|
||||
|
||||
fusion_preview_mode = fields.Selection([
|
||||
('default', 'Use User Preference'),
|
||||
('preview', 'Always Preview'),
|
||||
('download', 'Always Download'),
|
||||
('auto_print', 'Always Auto-Print'),
|
||||
], string='PDF Preview Mode', default='default',
|
||||
help='Override user-level PDF preview settings for this specific report.')
|
||||
|
||||
def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
|
||||
if tools.config['test_enable'] or tools.config['test_file']:
|
||||
return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data)
|
||||
|
||||
result = False, False
|
||||
messageError = False
|
||||
message_error = False
|
||||
try:
|
||||
result = super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data)
|
||||
except (UserError, ValidationError) as e:
|
||||
messageError = str(e)
|
||||
except Exception as e:
|
||||
messageError = traceback.format_exc()
|
||||
message_error = str(e)
|
||||
except Exception:
|
||||
message_error = traceback.format_exc()
|
||||
|
||||
if messageError:
|
||||
report_ref = "pdf_print_preview.report_error_catcher"
|
||||
data = {'error': messageError}
|
||||
if message_error:
|
||||
report_ref = "fusion_pdf_preview.report_error_catcher"
|
||||
data = {'error': message_error}
|
||||
result = super()._render_qweb_pdf(report_ref, res_ids=[], data=data)
|
||||
return result
|
||||
|
||||
37
fusion_pdf_preview/models/preview_log.py
Normal file
37
fusion_pdf_preview/models/preview_log.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class FusionPdfPreviewLog(models.Model):
|
||||
_name = 'fusion.pdf.preview.log'
|
||||
_description = 'PDF Preview Audit Log'
|
||||
_order = 'create_date desc'
|
||||
_rec_name = 'report_name'
|
||||
|
||||
user_id = fields.Many2one(
|
||||
'res.users', string='User',
|
||||
required=True, default=lambda self: self.env.uid,
|
||||
index=True,
|
||||
)
|
||||
report_id = fields.Many2one(
|
||||
'ir.actions.report', string='Report',
|
||||
ondelete='set null', index=True,
|
||||
)
|
||||
report_name = fields.Char(
|
||||
string='Report Name', required=True,
|
||||
help='Stored report name for reference even if the report is later deleted.',
|
||||
)
|
||||
action_type = fields.Selection([
|
||||
('preview', 'Preview'),
|
||||
('print', 'Print'),
|
||||
('download', 'Download'),
|
||||
], string='Action', required=True, index=True)
|
||||
record_ids = fields.Char(
|
||||
string='Record IDs',
|
||||
help='Comma-separated list of record IDs included in the report.',
|
||||
)
|
||||
model_name = fields.Char(
|
||||
string='Model',
|
||||
help='Technical model name of the records.',
|
||||
)
|
||||
42
fusion_pdf_preview/models/res_config_settings.py
Normal file
42
fusion_pdf_preview/models/res_config_settings.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
fpv_default_preview_print = fields.Boolean(
|
||||
string='Default Preview Print',
|
||||
config_parameter='fusion_pdf_preview.default_preview_print',
|
||||
default=True,
|
||||
help='Default value for PDF preview when new users are created.',
|
||||
)
|
||||
|
||||
fpv_default_automatic_printing = fields.Boolean(
|
||||
string='Default Automatic Printing',
|
||||
config_parameter='fusion_pdf_preview.default_automatic_printing',
|
||||
help='Default value for automatic printing when new users are created.',
|
||||
)
|
||||
|
||||
def action_fpv_apply_to_all_users(self):
|
||||
"""Apply current default PDF preview settings to all internal users in the company."""
|
||||
self.ensure_one()
|
||||
users = self.env['res.users'].search([
|
||||
('share', '=', False),
|
||||
('company_id', '=', self.env.company.id),
|
||||
])
|
||||
users.write({
|
||||
'preview_print': self.fpv_default_preview_print,
|
||||
'automatic_printing': self.fpv_default_automatic_printing,
|
||||
})
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'title': 'PDF Preview Settings',
|
||||
'message': f'Settings applied to {len(users)} user(s).',
|
||||
'type': 'success',
|
||||
'sticky': False,
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="action_report_pdf_print_preview" model="ir.actions.report">
|
||||
<field name="name">Pdf print preview</field>
|
||||
<record id="action_report_fusion_pdf_preview" model="ir.actions.report">
|
||||
<field name="name">Fusion PDF Preview</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">pdf_print_preview.report_error_catcher</field>
|
||||
<field name="report_name">fusion_pdf_preview.report_error_catcher</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<h5><b>Oops</b> Something went wrong when we printing the PDF:</h5>
|
||||
<h5><b>Oops!</b> Something went wrong while generating the PDF:</h5>
|
||||
<br/>
|
||||
<div class="alert alert-danger">
|
||||
<p><t t-esc="error" /></p>
|
||||
|
||||
3
fusion_pdf_preview/security/ir.model.access.csv
Normal file
3
fusion_pdf_preview/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_fusion_pdf_preview_log_user,fusion.pdf.preview.log.user,model_fusion_pdf_preview_log,base.group_user,0,0,1,0
|
||||
access_fusion_pdf_preview_log_admin,fusion.pdf.preview.log.admin,model_fusion_pdf_preview_log,base.group_system,1,1,1,1
|
||||
|
@@ -3,157 +3,41 @@
|
||||
<h4 class="oe_slogan">
|
||||
<span class="label label-info orders_label_text_align">
|
||||
<span class="fa fa-star-o fa-spin"></span>
|
||||
Pdf Print Preview
|
||||
Fusion PDF Preview
|
||||
</span>
|
||||
</h4>
|
||||
<section style="text-align: center;font-size: 24px;">
|
||||
<b> Preview and print PDF report in your browser </b>
|
||||
<b>Preview and print PDF reports directly in your browser</b>
|
||||
<p style="font-size: 16px;">by Nexa Systems Inc</p>
|
||||
</section>
|
||||
|
||||
<h4 class="oe_slogan">
|
||||
<span class="label label-success orders_label_text_align">
|
||||
<span class="fa fa-certificate fa-spin"></span>
|
||||
Feature
|
||||
Features
|
||||
</span>
|
||||
|
||||
</h4>
|
||||
<ul class="list-unstyled" style="font-size: 21px;">
|
||||
<li><i class="fa fa-check text-primary"></i> <b>PDF report preview, in current tab.</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>PDF report preview, in another tab.</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>Load report in another tab with print by default.</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>Pos, point of sale pdf report support. All odoo app like sale, purchase support.</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>In-browser PDF report preview dialog</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>Full-screen document viewing</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>One-click printing without download</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>Per-user configurable preview settings</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>Works with all Odoo apps (Sale, Purchase, POS, Stock, etc.)</b></li>
|
||||
<li><i class="fa fa-check text-primary"></i> <b>Compatible with Odoo 19 Community and Enterprise</b></li>
|
||||
</ul>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="label label-warning orders_label_text_align">
|
||||
<span class="fa fa-cog fa-spin"></span>
|
||||
Configuration
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_span12">
|
||||
<h4><i class="fa fa-star-o fa-spin"></i> <b>When a user is administrator he can update report preview for each user.</b></h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_1.PNG">
|
||||
</div>
|
||||
<h4><i class="fa fa-star-o fa-spin"></i> <b>When a user is administrator Or not administrator he can update report preview with this shortcut.</b></h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_2.PNG" />
|
||||
</div>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_3.PNG" />
|
||||
</div>
|
||||
<h4><i class="fa fa-star-o fa-spin"></i><b>Try to allow <b style='color: red;'>pop up</b> in your browser before preview report in another tab.</b>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_12.png" />
|
||||
</div>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_11.png" />
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="label label-success orders_label_text_align">
|
||||
Demo test
|
||||
</span>
|
||||
|
||||
</h4>
|
||||
|
||||
<div class="oe_span12">
|
||||
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_4.PNG">
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="orders_label_text_align">
|
||||
<b> Report preview </b>
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_5.PNG">
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="orders_label_text_align">
|
||||
<b> Full screen 1 </b>
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="report.png">
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="orders_label_text_align">
|
||||
<b> Full screen 2 </b>
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_7.png">
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="orders_label_text_align">
|
||||
<b> Print report </b>
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="print_report.png">
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="orders_label_text_align">
|
||||
<b> Load report in another tab with print by default </b>
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_9.PNG">
|
||||
</div>
|
||||
<h4 class="oe_slogan">
|
||||
<span class="orders_label_text_align">
|
||||
<b> Load report in another tab </b>
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<img src="config_10.PNG">
|
||||
</div>
|
||||
|
||||
<h4 class="oe_slogan">
|
||||
<span class="label label-warning orders_label_text_align">
|
||||
HTML5 Browser Support
|
||||
</span>
|
||||
</h4>
|
||||
<h4>
|
||||
<span>
|
||||
<i class="fa fa-check text-primary"> Print by default( <b>Automatic printing</b> ) is tested just with Chrome and Opera.
|
||||
</span>
|
||||
</h4>
|
||||
<h4>
|
||||
<span>
|
||||
<i class="fa fa-check text-primary"> Pdf print preview Compatible with all browser.
|
||||
</span>
|
||||
</h4>
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
<a class="btn btn-warning btn-lg" href="https://www.youtube.com/watch?v=hEXqt4moKts" target="_blank"><i class="fa fa-youtube" style="padding: 3px"></i>Click here to see it on youtube
|
||||
</a>
|
||||
<img src="https://www.itechgroup.info/web/image/product.product/10/image_1024/Pdf%20Print%20Preview%20%2817.0%29?unique=64031cc&utm_source=odoo-apps&utm_medium=link&utm_campaign=pdf-preview-17" style="display: none;"/>
|
||||
</div>
|
||||
<center>
|
||||
<img src="youtube.gif">
|
||||
</center>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="oe_container oe_dark">
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Technical Help & Support</h2>
|
||||
<h2 class="oe_slogan">Technical Help & Support</h2>
|
||||
</div>
|
||||
<div class="col-md-12 pad0">
|
||||
<div class="oe_mt16">
|
||||
<p><h4>For any type of technical help & support requests, Feel free to contact us</h4></p>
|
||||
<p><h4><span class="fa fa-language fa-spin"></span> <b>For custom translate please contact us</b></h4></p>
|
||||
<a class="btn btn-warning btn-lg" rel="nofollow" href="mailto:support@itechgroup.info"><span
|
||||
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
|
||||
<i class="fa fa-envelope" style="padding: 3px"></i> support@itechgroup.info
|
||||
</a>
|
||||
<a class="btn btn-warning btn-lg" rel="nofollow" href="mailto:contact@itechgroup.info"><span
|
||||
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
|
||||
<i class="fa fa-envelope" style="padding: 3px"></i> contact@itechgroup.info
|
||||
<p><h4>For any type of technical help & support requests, feel free to contact us</h4></p>
|
||||
<a class="btn btn-warning btn-lg" rel="nofollow" href="mailto:support@nexasystemsinc.com">
|
||||
<i class="fa fa-envelope" style="padding: 3px"></i> support@nexasystemsinc.com
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,12 +1,13 @@
|
||||
<section>
|
||||
<div class="row justify-content-center pt-4">
|
||||
<div class="col-12 text-center">
|
||||
<h4>Boost Efficiency with Odoo's Pdf Print Preview Module</h4>
|
||||
<h4>Fusion PDF Preview for Odoo</h4>
|
||||
<p class="text-muted">by Nexa Systems Inc</p>
|
||||
</div>
|
||||
<div class="col align-self-center">
|
||||
<p>
|
||||
Streamline your Odoo workflow and save time with the Pdf Print Preview
|
||||
module. This powerful tool allows you to conveniently preview reports
|
||||
Streamline your Odoo workflow and save time with Fusion PDF Preview.
|
||||
This powerful module allows you to conveniently preview reports
|
||||
directly within your browser, eliminating the need for constant
|
||||
downloads.
|
||||
</p>
|
||||
@@ -209,7 +210,7 @@
|
||||
No matter your role in Odoo, a convenient shortcut allows you to
|
||||
personalize your report preview. This means everyone can quickly
|
||||
adjust how they see reports, ensuring they have the information they
|
||||
need in the clearest format. this handy feature empowers you to take
|
||||
need in the clearest format. This handy feature empowers you to take
|
||||
control and optimize your Odoo experience.
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
@@ -231,7 +232,7 @@
|
||||
<section class="oe_container pb-2">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 pt-sm-4 pb-sm-4 pl-sm-1 pr-sm-5 pl-5 pr-5">
|
||||
<h5>Open PDF report in other tab & print</h5>
|
||||
<h5>Open PDF report in other tab & print</h5>
|
||||
This means the report wouldn't download to your computer, but instead,
|
||||
it would open within another browser tab, separate from the original
|
||||
webpage where you found the link or button.
|
||||
@@ -274,7 +275,7 @@
|
||||
opacity: 0.3;
|
||||
"
|
||||
></span>
|
||||
<b class="ps-2 pe-2">Demo test</b>
|
||||
<b class="ps-2 pe-2">Demo</b>
|
||||
<span
|
||||
class="d-none d-sm-inline-block"
|
||||
style="
|
||||
@@ -330,11 +331,9 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-4 pt-sm-4 pb-sm-4 pl-sm-1 pr-sm-5 pl-5 pr-5">
|
||||
<h5>Full Screen</h5>
|
||||
The <b>Full Screen</b> option in our module allows you to maximize the
|
||||
The Full Screen option allows you to maximize the
|
||||
document view for improved readability, focus, and clarity when
|
||||
reviewing documents. This is a convenient feature that enhances the
|
||||
user experience and facilitates better interaction with document
|
||||
content.
|
||||
reviewing documents.
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="oe_row_img oe_centered">
|
||||
@@ -356,11 +355,9 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-4 pt-sm-4 pb-sm-4 pl-sm-1 pr-sm-5 pl-5 pr-5">
|
||||
<h5>Print report</h5>
|
||||
<b>Print report</b> within document previews allow users to see how a
|
||||
Print report within document previews allows users to see how a
|
||||
document will appear when printed, facilitating verification of
|
||||
layout, formatting, and page breaks before sending it to the printer.
|
||||
This helps save time, reduce paper waste, and ensure a more
|
||||
professional-looking final document.
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="oe_row_img oe_centered">
|
||||
@@ -397,75 +394,36 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container">
|
||||
<div class="oe_row oe_spaced">
|
||||
<section class="oe_container pb-2">
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
<div class="oe_span12">
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
<a
|
||||
class="btn btn-warning btn-lg"
|
||||
href="https://youtu.be/aPYgzADUDKs"
|
||||
target="_blank"
|
||||
><i class="fa fa-youtube" style="padding: 3px"></i>Watch demo on
|
||||
YouTube!
|
||||
</a>
|
||||
<img
|
||||
src="https://tech58.odoo.com/r/uFs"
|
||||
style="display: none"
|
||||
src="assets/youtube.gif" class="oe_screenshot"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center pb-2">
|
||||
<img src="assets/youtube.gif" class="oe_screenshot "/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="oe_container oe_dark">
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Technical Help & Support</h2>
|
||||
<h2 class="oe_slogan">Technical Help & Support</h2>
|
||||
</div>
|
||||
<div class="col-md-12 pad0">
|
||||
<div class="oe_mt16">
|
||||
<h4>
|
||||
For any type of technical help & support requests, Feel free to
|
||||
For any type of technical help & support requests, feel free to
|
||||
contact us
|
||||
</h4>
|
||||
<h4>
|
||||
<span class="fa fa-language fa-spin"></span>
|
||||
<b>For custom translate please contact us</b>
|
||||
</h4>
|
||||
<a
|
||||
class="btn btn-warning btn-lg"
|
||||
rel="nofollow"
|
||||
href="mailto:support@itechgroup.info"
|
||||
><span
|
||||
style="
|
||||
height: 354px;
|
||||
width: 354px;
|
||||
top: -147.433px;
|
||||
left: -6.93335px;
|
||||
"
|
||||
class="o_ripple"
|
||||
></span>
|
||||
href="mailto:support@nexasystemsinc.com"
|
||||
>
|
||||
<i class="fa fa-envelope" style="padding: 3px"></i>
|
||||
support@itechgroup.info
|
||||
</a>
|
||||
<a
|
||||
class="btn btn-warning btn-lg"
|
||||
rel="nofollow"
|
||||
href="mailto:contact@itechgroup.info"
|
||||
><span
|
||||
style="
|
||||
height: 354px;
|
||||
width: 354px;
|
||||
top: -147.433px;
|
||||
left: -6.93335px;
|
||||
"
|
||||
class="o_ripple"
|
||||
></span>
|
||||
<i class="fa fa-envelope" style="padding: 3px"></i>
|
||||
contact@itechgroup.info
|
||||
support@nexasystemsinc.com
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,9 +5,27 @@ import { _t } from "@web/core/l10n/translation";
|
||||
import { session } from "@web/session";
|
||||
import { rpc } from "@web/core/network/rpc";
|
||||
import { user } from "@web/core/user";
|
||||
import { Component, useState, onMounted } from "@odoo/owl";
|
||||
import { Component, useState, onMounted, onWillUnmount } from "@odoo/owl";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
|
||||
|
||||
/**
|
||||
* Fire-and-forget audit log for PDF preview/print/download actions.
|
||||
*/
|
||||
async function logPreviewAction(reportName, actionType, recordIds, modelName) {
|
||||
try {
|
||||
await rpc("/fusion_pdf_preview/log_action", {
|
||||
report_name: reportName,
|
||||
action_type: actionType,
|
||||
record_ids: recordIds || '',
|
||||
model_name: modelName || '',
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn("Failed to log PDF preview action:", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class PDFViewerDialog extends Component {
|
||||
setup() {
|
||||
this.state = useState({
|
||||
@@ -15,10 +33,20 @@ export class PDFViewerDialog extends Component {
|
||||
viewerUrl: this.getViewerUrl(),
|
||||
isMaximized: false
|
||||
});
|
||||
|
||||
this._onKeyDown = this._onKeyDown.bind(this);
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('keydown', this._onKeyDown);
|
||||
});
|
||||
|
||||
onWillUnmount(() => {
|
||||
document.removeEventListener('keydown', this._onKeyDown);
|
||||
});
|
||||
}
|
||||
|
||||
getViewerUrl() {
|
||||
const baseUrl = '/pdf_print_preview/static/lib/pdfjs/web/viewer.html';
|
||||
const baseUrl = '/fusion_pdf_preview/static/lib/pdfjs/web/viewer.html';
|
||||
return `${baseUrl}?file=${this.props.url}`;
|
||||
}
|
||||
|
||||
@@ -43,20 +71,83 @@ export class PDFViewerDialog extends Component {
|
||||
}
|
||||
return 'height: calc(90vh - 100px) !important;';
|
||||
}
|
||||
|
||||
downloadPDF() {
|
||||
const link = document.createElement('a');
|
||||
link.href = this.props.url;
|
||||
link.download = this.props.title ? `${this.props.title}.pdf` : 'document.pdf';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
if (this.props.reportName) {
|
||||
logPreviewAction(this.props.reportName, 'download',
|
||||
this.props.recordIds, this.props.modelName);
|
||||
}
|
||||
}
|
||||
|
||||
openInNewTab() {
|
||||
window.open(this.props.url, '_blank');
|
||||
}
|
||||
|
||||
printPDF() {
|
||||
try {
|
||||
const iframe = this.el?.querySelector('iframe');
|
||||
if (iframe && iframe.contentWindow) {
|
||||
iframe.contentWindow.print();
|
||||
}
|
||||
} catch (err) {
|
||||
window.open(this.props.url, '_blank');
|
||||
}
|
||||
|
||||
if (this.props.reportName) {
|
||||
logPreviewAction(this.props.reportName, 'print',
|
||||
this.props.recordIds, this.props.modelName);
|
||||
}
|
||||
}
|
||||
|
||||
_onKeyDown(ev) {
|
||||
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
||||
const ctrlOrCmd = isMac ? ev.metaKey : ev.ctrlKey;
|
||||
|
||||
// F key (no modifiers) - toggle fullscreen
|
||||
if ((ev.key === 'f' || ev.key === 'F') && !ctrlOrCmd && !ev.altKey && !ev.shiftKey) {
|
||||
const activeEl = document.activeElement;
|
||||
if (activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA' || activeEl.isContentEditable)) {
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
this.toggle();
|
||||
}
|
||||
|
||||
// Ctrl+P / Cmd+P - print
|
||||
if (ctrlOrCmd && (ev.key === 'p' || ev.key === 'P')) {
|
||||
ev.preventDefault();
|
||||
this.printPDF();
|
||||
}
|
||||
|
||||
// Ctrl+D / Cmd+D - download
|
||||
if (ctrlOrCmd && (ev.key === 'd' || ev.key === 'D')) {
|
||||
ev.preventDefault();
|
||||
this.downloadPDF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PDFViewerDialog.template = 'pdf_print_preview.PDFViewerDialog';
|
||||
PDFViewerDialog.template = 'fusion_pdf_preview.PDFViewerDialog';
|
||||
PDFViewerDialog.components = { Dialog };
|
||||
|
||||
// Register for use in actions
|
||||
registry.category("dialog").add("PDFViewerDialog", PDFViewerDialog);
|
||||
|
||||
|
||||
export function openPDFViewer(env, url, title = "PDF Document") {
|
||||
export function openPDFViewer(env, url, title = "PDF Document", meta = {}) {
|
||||
const dialog = env.services.dialog;
|
||||
return dialog.add(PDFViewerDialog, {
|
||||
url: url,
|
||||
title: title
|
||||
title: title,
|
||||
reportName: meta.reportName || '',
|
||||
recordIds: meta.recordIds || '',
|
||||
modelName: meta.modelName || '',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +161,7 @@ function handleAutomaticPrinting(url, env) {
|
||||
const printFrame = document.createElement('iframe');
|
||||
printFrame.style.display = 'none';
|
||||
printFrame.src = url;
|
||||
|
||||
|
||||
printFrame.onload = function() {
|
||||
try {
|
||||
printFrame.contentWindow.print();
|
||||
@@ -88,12 +179,14 @@ function handleAutomaticPrinting(url, env) {
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
document.body.removeChild(printFrame);
|
||||
if (printFrame.parentNode) {
|
||||
document.body.removeChild(printFrame);
|
||||
}
|
||||
window.removeEventListener('focus', cleanup);
|
||||
};
|
||||
|
||||
window.addEventListener('focus', cleanup);
|
||||
|
||||
|
||||
document.body.appendChild(printFrame);
|
||||
}
|
||||
|
||||
@@ -103,15 +196,17 @@ function handleAutomaticPrinting(url, env) {
|
||||
*
|
||||
* @private
|
||||
* @param {ReportAction} action
|
||||
* @param {env} env
|
||||
* @param {Object} env
|
||||
* @param {string} filename
|
||||
* @returns {string}
|
||||
*/
|
||||
function _getReportUrl(action, env, filename) {
|
||||
let url = `/report/pdf/${action.report_name}`;
|
||||
const actionContext = action.context || {};
|
||||
filename = filename || action.name;
|
||||
if(filename !== undefined)
|
||||
if (filename !== undefined) {
|
||||
filename = filename.replace(/[/?%#&=]/g, "_") + ".pdf";
|
||||
}
|
||||
if (action.data && JSON.stringify(action.data) !== "{}") {
|
||||
const options = encodeURIComponent(JSON.stringify(action.data));
|
||||
const context = encodeURIComponent(JSON.stringify(actionContext));
|
||||
@@ -125,7 +220,7 @@ function _getReportUrl(action, env, filename) {
|
||||
return url;
|
||||
}
|
||||
|
||||
async function PdfPrintPreview(action, options, env) {
|
||||
async function FusionPdfPreview(action, options, env) {
|
||||
const link = '<br><br><a href="http://wkhtmltopdf.org/" target="_blank">wkhtmltopdf.org</a>';
|
||||
const WKHTMLTOPDF_MESSAGES = {
|
||||
broken:
|
||||
@@ -149,15 +244,17 @@ async function PdfPrintPreview(action, options, env) {
|
||||
),
|
||||
};
|
||||
|
||||
if (action.report_type === "qweb-pdf" && env.services.menu.getCurrentApp() !== undefined && (session.preview_print || session.automatic_printing)) {
|
||||
let getReportResult = rpc("/pdf_print_preview/get_report_name", {
|
||||
if (action.report_type === "qweb-pdf" && env.services.menu.getCurrentApp() !== undefined) {
|
||||
const userWantsPreview = session.preview_print;
|
||||
const userWantsAutoPrint = session.automatic_printing;
|
||||
|
||||
const result = await rpc("/fusion_pdf_preview/get_report_name", {
|
||||
report_name: action.report_name,
|
||||
data: JSON.stringify(action.context)
|
||||
});
|
||||
const result = await getReportResult;
|
||||
const state = result["wkhtmltopdf_state"];
|
||||
const previewMode = result["fusion_preview_mode"] || "default";
|
||||
|
||||
// display a notification according to wkhtmltopdf's state
|
||||
if (state in WKHTMLTOPDF_MESSAGES) {
|
||||
env.services.notification.add(WKHTMLTOPDF_MESSAGES[state], {
|
||||
sticky: true,
|
||||
@@ -166,14 +263,40 @@ async function PdfPrintPreview(action, options, env) {
|
||||
}
|
||||
|
||||
if (state === "upgrade" || state === "ok") {
|
||||
let url = _getReportUrl(action, env, result["file_name"]);
|
||||
if(session.preview_print) {
|
||||
// PreviewDialog.createPreviewDialog(self, url, action.name);
|
||||
openPDFViewer(env, url, action.name);
|
||||
// Determine effective behavior based on report-level override
|
||||
let shouldPreview = userWantsPreview;
|
||||
let shouldAutoPrint = userWantsAutoPrint;
|
||||
|
||||
if (previewMode === 'preview') {
|
||||
shouldPreview = true;
|
||||
shouldAutoPrint = false;
|
||||
} else if (previewMode === 'download') {
|
||||
return false;
|
||||
} else if (previewMode === 'auto_print') {
|
||||
shouldPreview = false;
|
||||
shouldAutoPrint = true;
|
||||
}
|
||||
|
||||
if (session.automatic_printing) {
|
||||
if (!shouldPreview && !shouldAutoPrint) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const url = _getReportUrl(action, env, result["file_name"]);
|
||||
const actionContext = action.context || {};
|
||||
const meta = {
|
||||
reportName: action.report_name,
|
||||
recordIds: (actionContext.active_ids || []).join(','),
|
||||
modelName: actionContext.active_model || '',
|
||||
};
|
||||
|
||||
if (shouldPreview) {
|
||||
openPDFViewer(env, url, action.name, meta);
|
||||
logPreviewAction(meta.reportName, 'preview', meta.recordIds, meta.modelName);
|
||||
}
|
||||
|
||||
if (shouldAutoPrint) {
|
||||
handleAutomaticPrinting(url, env);
|
||||
logPreviewAction(meta.reportName, 'print', meta.recordIds, meta.modelName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -182,4 +305,4 @@ async function PdfPrintPreview(action, options, env) {
|
||||
|
||||
registry
|
||||
.category("ir.actions.report handlers")
|
||||
.add("pdf_print_preview", PdfPrintPreview);
|
||||
.add("fusion_pdf_preview", FusionPdfPreview);
|
||||
|
||||
@@ -13,7 +13,7 @@ function reportPreviewConfigItem(env) {
|
||||
description: _t("Report preview"),
|
||||
callback: async function () {
|
||||
const actionDescription = await rpc("/web/action/load", {
|
||||
action_id: "pdf_print_preview.action_short_preview_print"
|
||||
action_id: "fusion_pdf_preview.action_short_preview_print"
|
||||
});
|
||||
actionDescription.res_id = user.userId;
|
||||
env.services.action.doAction(actionDescription);
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="pdf_print_preview.PDFViewerDialog">
|
||||
<t t-name="fusion_pdf_preview.PDFViewerDialog">
|
||||
<Dialog size="getDialogSize()" footer="false">
|
||||
<t t-set-slot="header">
|
||||
<div class="d-flex align-items-center justify-content-between flex w-100">
|
||||
<div style="width: 90px"></div>
|
||||
<div style="width: 135px"></div>
|
||||
<h4 class="modal-title text-break fw-normal">
|
||||
<b><t t-esc="props.title" /></b>
|
||||
</h4>
|
||||
<div class="d-flex align-items-center" style="width: 45px">
|
||||
<button type="button" class="btn" t-on-click="toggle">
|
||||
<div class="d-flex align-items-center" style="width: 135px; justify-content: flex-end;">
|
||||
<button type="button" class="btn" t-on-click="downloadPDF" title="Download (Ctrl+D)">
|
||||
<i class="fa fa-download"/>
|
||||
</button>
|
||||
<button type="button" class="btn" t-on-click="openInNewTab" title="Open in new tab">
|
||||
<i class="fa fa-external-link"/>
|
||||
</button>
|
||||
<button type="button" class="btn" t-on-click="toggle" title="Toggle fullscreen (F)">
|
||||
<i t-if="!state.isMaximized" class="fa fa-square-o" />
|
||||
<i t-else="" class="fa fa-clone" />
|
||||
</button>
|
||||
@@ -17,17 +23,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
|
||||
<div class="o_pdf_viewer position-relative">
|
||||
<!-- Loading spinner -->
|
||||
<div t-if="state.isLoading"
|
||||
class="position-absolute w-100 h-100 d-flex justify-content-center align-items-center"
|
||||
<div t-if="state.isLoading"
|
||||
class="position-absolute w-100 h-100 d-flex justify-content-center align-items-center"
|
||||
style="z-index: 1;">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- PDF.js viewer iframe -->
|
||||
<iframe t-att-src="state.viewerUrl"
|
||||
class="w-100 border-0"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<odoo>
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="//link[last()]" position="after">
|
||||
<link rel="stylesheet" type="text/scss" href="/pdf_print_preview/static/src/scss/dialog.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/pdf_print_preview/static/src/scss/content.scss"/>
|
||||
</xpath>
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/pdf_print_preview/static/src/js/dialog.js"/>
|
||||
<script type="text/javascript" src="/pdf_print_preview/static/src/js/pdf_preview.js"/>
|
||||
<script type="text/javascript" src="/pdf_print_preview/static/src/js/user_menu.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
13
fusion_pdf_preview/views/ir_actions_report_views.xml
Normal file
13
fusion_pdf_preview/views/ir_actions_report_views.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="act_report_xml_view_fusion_pdf_preview" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.form.fusion.pdf.preview</field>
|
||||
<field name="model">ir.actions.report</field>
|
||||
<field name="inherit_id" ref="base.act_report_xml_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='print_report_name']" position="after">
|
||||
<field name="fusion_preview_mode"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
66
fusion_pdf_preview/views/preview_log_views.xml
Normal file
66
fusion_pdf_preview/views/preview_log_views.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<!-- Tree View -->
|
||||
<record id="fusion_pdf_preview_log_tree" model="ir.ui.view">
|
||||
<field name="name">fusion.pdf.preview.log.tree</field>
|
||||
<field name="model">fusion.pdf.preview.log</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="PDF Preview Audit Log" create="0" edit="0" delete="0">
|
||||
<field name="create_date" string="Date"/>
|
||||
<field name="user_id"/>
|
||||
<field name="report_name"/>
|
||||
<field name="action_type"/>
|
||||
<field name="model_name"/>
|
||||
<field name="record_ids"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Form View -->
|
||||
<record id="fusion_pdf_preview_log_form" model="ir.ui.view">
|
||||
<field name="name">fusion.pdf.preview.log.form</field>
|
||||
<field name="model">fusion.pdf.preview.log</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="PDF Preview Log Entry" create="0" edit="0" delete="0">
|
||||
<sheet>
|
||||
<group>
|
||||
<group string="Details">
|
||||
<field name="create_date"/>
|
||||
<field name="user_id"/>
|
||||
<field name="action_type"/>
|
||||
</group>
|
||||
<group string="Report">
|
||||
<field name="report_id"/>
|
||||
<field name="report_name"/>
|
||||
<field name="model_name"/>
|
||||
<field name="record_ids"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action -->
|
||||
<record id="action_fusion_pdf_preview_log" model="ir.actions.act_window">
|
||||
<field name="name">PDF Preview Audit Log</field>
|
||||
<field name="res_model">fusion.pdf.preview.log</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
No PDF preview activity has been logged yet.
|
||||
</p>
|
||||
<p>
|
||||
This log tracks when users preview, print, or download PDF reports.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Menu Item under Settings -->
|
||||
<menuitem id="menu_fusion_pdf_preview_log"
|
||||
name="PDF Preview Log"
|
||||
action="action_fusion_pdf_preview_log"
|
||||
parent="base.menu_administration"
|
||||
sequence="99"
|
||||
groups="base.group_system"/>
|
||||
</odoo>
|
||||
59
fusion_pdf_preview/views/res_config_settings_views.xml
Normal file
59
fusion_pdf_preview/views/res_config_settings_views.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form_fusion_pdf_preview" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.fusion.pdf.preview</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form" position="inside">
|
||||
<app data-string="Fusion PDF Preview" string="Fusion PDF Preview" name="fusion_pdf_preview">
|
||||
<h2>Default Settings</h2>
|
||||
<div class="row mt-4 o_settings_container">
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="fpv_default_preview_print"/>
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="fpv_default_preview_print"/>
|
||||
<div class="text-muted">
|
||||
Enable PDF preview in a dialog by default for new users.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="fpv_default_automatic_printing"/>
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="fpv_default_automatic_printing"/>
|
||||
<div class="text-muted">
|
||||
Enable automatic printing by default for new users.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Bulk Actions</h2>
|
||||
<div class="row mt-4 o_settings_container">
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_right_pane">
|
||||
<span class="o_form_label">Apply to All Users</span>
|
||||
<div class="text-muted">
|
||||
Apply the above default settings to all current internal users in this company.
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button name="action_fpv_apply_to_all_users"
|
||||
type="object"
|
||||
string="Apply to All Users"
|
||||
class="btn-primary"
|
||||
icon="fa-users"
|
||||
confirm="This will overwrite PDF preview preferences for all internal users in the current company. Continue?"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</app>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
<odoo>
|
||||
<record id="view_users_preview_print_form" model="ir.ui.view">
|
||||
<field name="name">res.users.form.inherit</field>
|
||||
<field name="name">res.users.form.inherit.fusion.pdf.preview</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="Preview">
|
||||
<page string="PDF Preview">
|
||||
<group>
|
||||
<group string="Report">
|
||||
<field name="preview_print"/>
|
||||
@@ -20,13 +20,12 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="short_preview_print_from" model="ir.ui.view">
|
||||
<record id="short_preview_print_form" model="ir.ui.view">
|
||||
<field name="name">res.users.preview_print.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field eval="18" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Users" edit="1">
|
||||
<form string="PDF Preview Settings" edit="1">
|
||||
<field name="image_1920" readonly="0" widget="image" class="oe_avatar" options="{'zoom': true, 'preview_image': 'image_128'}"/>
|
||||
<h1>
|
||||
<field name="name" readonly="1" class="oe_inline"/>
|
||||
@@ -46,7 +45,7 @@
|
||||
</record>
|
||||
|
||||
<record id="action_short_preview_print" model="ir.actions.act_window">
|
||||
<field name="name">Preview Print</field>
|
||||
<field name="name">PDF Preview Settings</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">res.users</field>
|
||||
<field name="target">new</field>
|
||||
@@ -56,7 +55,7 @@
|
||||
<record id="action_short_preview_print2" model="ir.actions.act_window.view">
|
||||
<field eval="10" name="sequence"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="short_preview_print_from"/>
|
||||
<field name="view_id" ref="short_preview_print_form"/>
|
||||
<field name="act_window_id" ref="action_short_preview_print"/>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user