mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
report_async
This commit is contained in:
committed by
Atchuthan, Sodexis
parent
b2e8ae48ca
commit
323ac96836
4
report_async/wizard/__init__.py
Normal file
4
report_async/wizard/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from . import print_report_wizard
|
||||
43
report_async/wizard/print_report_wizard.py
Normal file
43
report_async/wizard/print_report_wizard.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class PrintReportWizard(models.TransientModel):
|
||||
_name = 'print.report.wizard'
|
||||
_description = 'Print Report Wizard'
|
||||
|
||||
reference = fields.Reference(
|
||||
string='Document',
|
||||
selection='_reference_models',
|
||||
required=True,
|
||||
)
|
||||
action_report_id = fields.Many2one(
|
||||
comodel_name='ir.actions.report',
|
||||
string='Report Template',
|
||||
required=True,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _reference_models(self):
|
||||
excludes = ['res.company']
|
||||
models = self.env['ir.model'].search([
|
||||
('state', '!=', 'manual'), ('transient', '=', False),
|
||||
('model', 'not in', excludes)])
|
||||
return [(model.model, model.name) for model in models]
|
||||
|
||||
@api.onchange('reference')
|
||||
def _onchange_reference(self):
|
||||
self.ensure_one()
|
||||
domain = [('id', 'in', [])]
|
||||
self.action_report_id = False
|
||||
if self.reference:
|
||||
domain = [('model', '=', self.reference._name)]
|
||||
return {'domain': {'action_report_id': domain}}
|
||||
|
||||
@api.multi
|
||||
def print_report(self):
|
||||
self.ensure_one()
|
||||
return self.action_report_id.report_action(self.reference,
|
||||
config=False)
|
||||
36
report_async/wizard/print_report_wizard.xml
Normal file
36
report_async/wizard/print_report_wizard.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="print_report_wizard" model="ir.ui.view">
|
||||
<field name="name">print.report.wizard</field>
|
||||
<field name="model">print.report.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group>
|
||||
<group>
|
||||
<field name="reference"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="action_report_id" options="{'no_open': True, 'no_create_edit': True}"/>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="print_report"
|
||||
type="object" string="Execute"
|
||||
class="oe_highlight"/>
|
||||
<button special="cancel"
|
||||
string="Cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_print_report_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Print Document</field>
|
||||
<field name="res_model">print.report.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user