Skip to content

Commit b923a48

Browse files
committed
refactoring
1 parent 69e207d commit b923a48

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

report_py3o/static/src/js/py3oactionservice.esm.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ registry
1010
let url = `/report/py3o/${action.report_name}`;
1111
const actionContext = action.context || {};
1212
if (
13-
action.data === "undefined"||
14-
action.data == null ||
15-
(_typeof(action.data) === 'object' && action.data !== null)
13+
typeof action.data === "undefined" ||
14+
action.data === null ||
15+
typeof action.data === "object"
1616
) {
1717
// Build a query string with `action.data` (it's the place where reports
1818
// using a wizard to customize the output traditionally put their options)

report_py3o/tests/test_report_py3o.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@
55
import logging
66
import os
77
import shutil
8+
import sys
89
import tempfile
910
from base64 import b64decode, b64encode
1011
from contextlib import contextmanager
1112
from unittest import mock
12-
from packaging import version
13-
import sys
14-
15-
# Ensuring compatibility with PyPDF2 versions depending on the Python version
16-
PYTHON_VERSION = version.parse(sys.version)
17-
18-
# Conditional import based on Python version
19-
if PYTHON_VERSION <= version.parse("3.10"):
20-
from PyPDF2.pdf import PageObject
21-
else:
22-
from PyPDF2 import PageObject
2313

14+
import pkg_resources
15+
from packaging import version
16+
from PyPDF2 import PdfFileWriter
2417

2518
from odoo import tools
2619
from odoo.exceptions import ValidationError
@@ -39,6 +32,15 @@
3932
except ImportError:
4033
logger.debug("Cannot import genshi.core")
4134

35+
# Ensuring compatibility with PyPDF2 versions depending on the Python version
36+
PYTHON_VERSION = version.parse(sys.version)
37+
38+
# Conditional import based on Python version
39+
if PYTHON_VERSION <= version.parse("3.10"):
40+
from PyPDF2.pdf import PageObject
41+
else:
42+
from PyPDF2 import PageObject
43+
4244

4345
@contextmanager
4446
def temporary_copy(path):

report_py3o/views/ir_actions_report.xml

+17-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
<field name="arch" type="xml">
99
<xpath expr="/form/field[1]" position="before">
1010
<field name="is_py3o_report_not_available" invisible="1" />
11-
<div class="alert alert-danger" role="alert" style="margin-bottom:0px;" invisible="is_py3o_report_not_available == False">
11+
<div
12+
class="alert alert-danger"
13+
role="alert"
14+
style="margin-bottom:0px;"
15+
invisible="is_py3o_report_not_available == False"
16+
>
1217
<field name="msg_py3o_report_not_available" />
1318
</div>
1419
</xpath>
1520
<xpath expr="//page[@name='security']" position="before">
16-
<page string="LibreOffice Template" name="py3o_tab" invisible="report_type != 'py3o'">
21+
<page
22+
string="LibreOffice Template"
23+
name="py3o_tab"
24+
invisible="report_type != 'py3o'"
25+
>
1726
<group name="py3o_params">
1827
<field name="lo_bin_path" />
1928
<field name="py3o_filetype" />
@@ -32,8 +41,12 @@
3241
<field name="inherit_id" ref="base.act_report_xml_search_view" />
3342
<field name="arch" type="xml">
3443
<field name="model" position="after">
35-
<field name="report_type" invisible="1"/>
36-
<filter name="py3o" string="Py3o Reports" domain="[('report_type', '=', 'py3o')]" />
44+
<field name="report_type" invisible="1" />
45+
<filter
46+
name="py3o"
47+
string="Py3o Reports"
48+
domain="[('report_type', '=', 'py3o')]"
49+
/>
3750
</field>
3851
</field>
3952
</record>

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# generated from manifests external_dependencies
22
lxml
3+
py3o.formats
4+
py3o.template
35
xlrd
46
xlsxwriter

0 commit comments

Comments
 (0)