This commit is contained in:
parent
46d68a026b
commit
b2a117ecdf
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
from . import models
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
'name': 'Pdf report options',
|
||||
'version': '18.0.1.0.0', # تحديث الإصدار
|
||||
'summary': """shows a modal window with options for printing, downloading or opening pdf reports""",
|
||||
'description': """...""",
|
||||
'author': 'Luis Rodrigo Mejia Mateus, Odoo SA',
|
||||
'category': 'Odex30-Base',
|
||||
'images': ['images/main_1.png', 'images/main_screenshot.png'],
|
||||
'depends': ['web'],
|
||||
'data': [
|
||||
'views/ir_actions_report.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'report_pdf_options/static/src/js/qwebactionmanager.js',
|
||||
],
|
||||
},
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'license': 'LGPL-3'
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * print_attachment_options
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-29 02:35+0000\n"
|
||||
"PO-Revision-Date: 2019-05-28 21:41-0500\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: \n"
|
||||
"Language: es_PE\n"
|
||||
"X-Generator: Poedit 2.2.3\n"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#. openerp-web
|
||||
#: code:addons/print_attachment_options/static/src/js/qwebactionmanager.js:134
|
||||
#, python-format
|
||||
msgid "Close"
|
||||
msgstr "Cerrar"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#: model:ir.model.fields,field_description:print_attachment_options.field_ir_act_report_xml_default_print_option
|
||||
msgid "Default printing option"
|
||||
msgstr "Opción de impresión predeterminada"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#. openerp-web
|
||||
#: code:addons/print_attachment_options/static/src/xml/print_attachment_options.xml:12
|
||||
#: selection:ir.actions.report.xml,default_print_option:0
|
||||
#, python-format
|
||||
msgid "Download"
|
||||
msgstr "Descargar"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#. openerp-web
|
||||
#: code:addons/print_attachment_options/static/src/xml/print_attachment_options.xml:16
|
||||
#: selection:ir.actions.report.xml,default_print_option:0
|
||||
#, python-format
|
||||
msgid "Open"
|
||||
msgstr "Abrir"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#. openerp-web
|
||||
#: code:addons/print_attachment_options/static/src/xml/print_attachment_options.xml:8
|
||||
#: selection:ir.actions.report.xml,default_print_option:0
|
||||
#, python-format
|
||||
msgid "Print"
|
||||
msgstr "Imprimir"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#. openerp-web
|
||||
#: code:addons/print_attachment_options/static/src/js/qwebactionmanager.js:96
|
||||
#, python-format
|
||||
msgid "Report"
|
||||
msgstr "Reporte"
|
||||
|
||||
#. module: print_attachment_options
|
||||
#. openerp-web
|
||||
#: code:addons/print_attachment_options/static/src/js/qwebactionmanager.js:131
|
||||
#, python-format
|
||||
msgid "What do you want to do?"
|
||||
msgstr "¿Qué quieres hacer?"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 194 KiB |
|
|
@ -0,0 +1 @@
|
|||
from . import ir_actions
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class IrActionsReportXml(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
|
||||
default_print_option = fields.Selection(selection=[
|
||||
('print', 'Print'),
|
||||
('download', 'Download'),
|
||||
('open', 'Open')
|
||||
], string='Default printing option')
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
|
|
@ -0,0 +1,41 @@
|
|||
<section class="oe_container">
|
||||
<div class="oe_row oe_spaced">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Report Print Options</h2>
|
||||
<h3 class="oe_slogan">Report direct print, download or open in new tab</h3>
|
||||
</div>
|
||||
<div class="oe_span12">
|
||||
<div class="oe_demo oe_pictue oe_screenshot">
|
||||
<img src="printoptions.gif">
|
||||
</div>
|
||||
<div class="oe_demo oe_pictue oe_screenshot">
|
||||
<img src="printoptions2.gif">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container oe_dark">
|
||||
<div class="oe_row oe_spaced">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Report Print Configuration</h2>
|
||||
<h3 class="oe_slogan">Set an option to perform by default</h3>
|
||||
</div>
|
||||
<div class="oe_span12">
|
||||
<div class="oe_demo oe_pictue oe_screenshot">
|
||||
<img src="setupoptions.gif">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container">
|
||||
<div class="oe_row oe_spaced">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">The default option is executed</h2>
|
||||
</div>
|
||||
<div class="oe_span12">
|
||||
<div class="oe_demo oe_pictue oe_screenshot">
|
||||
<img src="defaultoption.gif">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 246 KiB |
|
|
@ -0,0 +1,103 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { Component, xml } from "@odoo/owl";
|
||||
import * as reportUtils from "@web/webclient/actions/reports/utils";
|
||||
import { rpc } from "@web/core/network/rpc";
|
||||
|
||||
class ReportOptionDialog extends Component {
|
||||
static template = xml`
|
||||
<Dialog title="'What do you want to do?'" size="'md'">
|
||||
<div class="text-center p-3">
|
||||
<div class="btn-group" role="group" aria-label="Print Options">
|
||||
<button class="btn btn-primary btn-pdf" t-on-click="() => this.onButtonClick('print')">
|
||||
<i class="fa fa-print me-1"/>
|
||||
<span>Print</span>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-pdf" t-on-click="() => this.onButtonClick('download')">
|
||||
<i class="fa fa-download me-1"/>
|
||||
<span>Download</span>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-pdf" t-on-click="() => this.onButtonClick('open')">
|
||||
<i class="fa fa-file-text me-1"/>
|
||||
<span>Open</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<t t-set-slot="footer">
|
||||
<button class="btn btn-light" t-on-click="props.close">Close</button>
|
||||
</t>
|
||||
</Dialog>
|
||||
`;
|
||||
static components = { Dialog };
|
||||
|
||||
onButtonClick(option) {
|
||||
this.props.onSelect(option);
|
||||
this.props.close();
|
||||
}
|
||||
}
|
||||
|
||||
const pdfOptionsHandler = async (action, options, env) => {
|
||||
if (action.report_type !== 'qweb-pdf' || (options && options.download === false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const dialogService = env.services.dialog;
|
||||
const notification = env.services.notification;
|
||||
const { getReportUrl, downloadReport } = reportUtils;
|
||||
|
||||
const userContext = env.services.user?.context || {};
|
||||
|
||||
const status = await rpc("/report/check_wkhtmltopdf");
|
||||
|
||||
if (status === 'install' || status === 'broken') {
|
||||
notification.add(env._t("Wkhtmltopdf is not properly installed."), { type: 'warning' });
|
||||
} else if (status === 'upgrade') {
|
||||
notification.add(env._t("For better reports, you should upgrade wkhtmltopdf."), { type: 'info' });
|
||||
}
|
||||
|
||||
if (!["upgrade", "ok"].includes(status)) {
|
||||
env.services.action.doAction(action, { additionalContext: { html_report: true } });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.default_print_option) {
|
||||
if (action.default_print_option === 'print') {
|
||||
const url = getReportUrl(action, 'html', userContext);
|
||||
|
||||
} else {
|
||||
downloadReport(rpc, action, 'pdf', userContext);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const onSelect = (option) => {
|
||||
if (option === 'print') {
|
||||
const url = getReportUrl(action, 'html', userContext);
|
||||
const printIframe = document.createElement("iframe");
|
||||
printIframe.style.display = "none";
|
||||
document.body.appendChild(printIframe);
|
||||
printIframe.onload = () => {
|
||||
printIframe.contentWindow.print();
|
||||
setTimeout(() => document.body.removeChild(printIframe), 1000);
|
||||
};
|
||||
printIframe.src = url;
|
||||
} else if (option === 'open') {
|
||||
const url = getReportUrl(action, 'pdf', userContext);
|
||||
window.open(url, '_blank');
|
||||
} else {
|
||||
downloadReport(rpc, action, 'pdf', userContext);
|
||||
}
|
||||
resolve(true);
|
||||
};
|
||||
|
||||
dialogService.add(ReportOptionDialog, {
|
||||
onSelect: onSelect,
|
||||
onClose: () => resolve(true),
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
registry.category("ir.actions.report handlers").add("pdf_options_handler", pdfOptionsHandler, { sequence: 1 });
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="act_report_view_inherit" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.inherit</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="//page[@name='advanced']" position="inside">
|
||||
<group>
|
||||
<field name="default_print_option"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue