-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] report_fillpdf: black, isort, prettier
- Loading branch information
Showing
12 changed files
with
144 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
# Copyright 2017 Creu Blanca | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
'name': "Base report PDF Filler", | ||
|
||
'summary': """ | ||
"name": "Base report PDF Filler", | ||
"summary": """ | ||
Base module that fills PDFs""", | ||
'author': 'Creu Blanca,' | ||
'Odoo Community Association (OCA)', | ||
'website': "http://github.com/oca/reporting-engine", | ||
'category': 'Reporting', | ||
'version': '11.0.1.0.1', | ||
'license': 'AGPL-3', | ||
'external_dependencies': { | ||
'python': [ | ||
'fdfgen', | ||
"author": "Creu Blanca," "Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/reporting-engine", | ||
"category": "Reporting", | ||
"version": "11.0.1.0.1", | ||
"license": "AGPL-3", | ||
"external_dependencies": { | ||
"python": [ | ||
"fdfgen", | ||
], | ||
"bin": [ | ||
"pdftk", | ||
], | ||
'bin': [ | ||
'pdftk', | ||
] | ||
}, | ||
'depends': [ | ||
'base', 'web', | ||
"depends": [ | ||
"base", | ||
"web", | ||
], | ||
'data': [ | ||
'views/webclient_templates.xml', | ||
"data": [ | ||
"views/webclient_templates.xml", | ||
], | ||
'demo': [ | ||
'demo/report.xml', | ||
"demo": [ | ||
"demo/report.xml", | ||
], | ||
'installable': True, | ||
"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
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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
# Copyright 2017 Creu Blanca | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models, _ | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class ReportAction(models.Model): | ||
_inherit = 'ir.actions.report' | ||
_inherit = "ir.actions.report" | ||
|
||
report_type = fields.Selection(selection_add=[("fillpdf", "PDF Filler")]) | ||
|
||
@api.model | ||
def render_fillpdf(self, docids, data): | ||
report_model_name = 'report.%s' % self.report_name | ||
report_model_name = "report.%s" % self.report_name | ||
report_model = self.env.get(report_model_name) | ||
if report_model is None: | ||
raise UserError(_('%s model was not found' % report_model_name)) | ||
return report_model.with_context({ | ||
'active_model': self.model | ||
}).fill_report(docids, data) | ||
raise UserError(_("%s model was not found" % report_model_name)) | ||
return report_model.with_context({"active_model": self.model}).fill_report( | ||
docids, data | ||
) | ||
|
||
@api.model | ||
def _get_report_from_name(self, report_name): | ||
res = super(ReportAction, self)._get_report_from_name(report_name) | ||
if res: | ||
return res | ||
report_obj = self.env['ir.actions.report'] | ||
qwebtypes = ['fillpdf'] | ||
conditions = [('report_type', 'in', qwebtypes), | ||
('report_name', '=', report_name)] | ||
context = self.env['res.users'].context_get() | ||
report_obj = self.env["ir.actions.report"] | ||
qwebtypes = ["fillpdf"] | ||
conditions = [ | ||
("report_type", "in", qwebtypes), | ||
("report_name", "=", report_name), | ||
] | ||
context = self.env["res.users"].context_get() | ||
return report_obj.with_context(context).search(conditions, limit=1) |
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 |
---|---|---|
@@ -1,42 +1,49 @@ | ||
// © 2017 Creu Blanca | ||
// License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html). | ||
odoo.define('report_fillpdf.report', function(require){ | ||
'use strict'; | ||
odoo.define("report_fillpdf.report", function (require) { | ||
"use strict"; | ||
|
||
var ActionManager= require('web.ActionManager'); | ||
var crash_manager = require('web.crash_manager'); | ||
var framework = require('web.framework'); | ||
var ActionManager = require("web.ActionManager"); | ||
var crash_manager = require("web.crash_manager"); | ||
var framework = require("web.framework"); | ||
|
||
ActionManager.include({ | ||
ir_actions_report: function (action, options){ | ||
var self = this; | ||
var cloned_action = _.clone(action); | ||
if (cloned_action.report_type === 'fillpdf') { | ||
framework.blockUI(); | ||
var report_fillpdf_url = 'report/fillpdf/' + cloned_action.report_name; | ||
if(cloned_action.context.active_ids){ | ||
report_fillpdf_url += '/' + cloned_action.context.active_ids.join(','); | ||
}else{ | ||
report_fillpdf_url += '?options=' + encodeURIComponent(JSON.stringify(cloned_action.data)); | ||
report_fillpdf_url += '&context=' + encodeURIComponent(JSON.stringify(cloned_action.context)); | ||
} | ||
self.getSession().get_file({ | ||
url: report_fillpdf_url, | ||
data: {data: JSON.stringify([ | ||
report_fillpdf_url, | ||
cloned_action.report_type | ||
])}, | ||
error: crash_manager.rpc_error.bind(crash_manager), | ||
success: function (){ | ||
if(cloned_action && options && !cloned_action.dialog){ | ||
options.on_close(); | ||
} | ||
ActionManager.include({ | ||
ir_actions_report: function (action, options) { | ||
var self = this; | ||
var cloned_action = _.clone(action); | ||
if (cloned_action.report_type === "fillpdf") { | ||
framework.blockUI(); | ||
var report_fillpdf_url = "report/fillpdf/" + cloned_action.report_name; | ||
if (cloned_action.context.active_ids) { | ||
report_fillpdf_url += | ||
"/" + cloned_action.context.active_ids.join(","); | ||
} else { | ||
report_fillpdf_url += | ||
"?options=" + | ||
encodeURIComponent(JSON.stringify(cloned_action.data)); | ||
report_fillpdf_url += | ||
"&context=" + | ||
encodeURIComponent(JSON.stringify(cloned_action.context)); | ||
} | ||
}); | ||
framework.unblockUI(); | ||
return; | ||
} | ||
return self._super(action, options); | ||
} | ||
}); | ||
self.getSession().get_file({ | ||
url: report_fillpdf_url, | ||
data: { | ||
data: JSON.stringify([ | ||
report_fillpdf_url, | ||
cloned_action.report_type, | ||
]), | ||
}, | ||
error: crash_manager.rpc_error.bind(crash_manager), | ||
success: function () { | ||
if (cloned_action && options && !cloned_action.dialog) { | ||
options.on_close(); | ||
} | ||
}, | ||
}); | ||
framework.unblockUI(); | ||
return; | ||
} | ||
return self._super(action, options); | ||
}, | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# generated from manifests external_dependencies | ||
cryptography | ||
endesive | ||
fdfgen | ||
py3o.formats | ||
py3o.template |
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 @@ | ||
../../../../report_fillpdf |
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,2 @@ | ||
[bdist_wheel] | ||
universal=1 |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |