odoo-addon-base-report-to-printer 17.0.1.1.1__py3-none-any.whl → 18.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of odoo-addon-base-report-to-printer might be problematic. Click here for more details.
- odoo/addons/base_report_to_printer/README.rst +52 -45
- odoo/addons/base_report_to_printer/__manifest__.py +1 -1
- odoo/addons/base_report_to_printer/data/printing_data.xml +5 -11
- odoo/addons/base_report_to_printer/i18n/am.po +17 -47
- odoo/addons/base_report_to_printer/i18n/base_report_to_printer.pot +1 -12
- odoo/addons/base_report_to_printer/i18n/bg.po +17 -47
- odoo/addons/base_report_to_printer/i18n/ca.po +17 -47
- odoo/addons/base_report_to_printer/i18n/de.po +19 -64
- odoo/addons/base_report_to_printer/i18n/el_GR.po +17 -47
- odoo/addons/base_report_to_printer/i18n/es.po +19 -64
- odoo/addons/base_report_to_printer/i18n/es_AR.po +19 -64
- odoo/addons/base_report_to_printer/i18n/es_ES.po +17 -47
- odoo/addons/base_report_to_printer/i18n/fi.po +17 -47
- odoo/addons/base_report_to_printer/i18n/fr.po +19 -64
- odoo/addons/base_report_to_printer/i18n/gl.po +17 -47
- odoo/addons/base_report_to_printer/i18n/hr.po +20 -53
- odoo/addons/base_report_to_printer/i18n/hr_HR.po +19 -49
- odoo/addons/base_report_to_printer/i18n/it.po +19 -65
- odoo/addons/base_report_to_printer/i18n/nl.po +17 -47
- odoo/addons/base_report_to_printer/i18n/nl_NL.po +17 -47
- odoo/addons/base_report_to_printer/i18n/pt.po +17 -47
- odoo/addons/base_report_to_printer/i18n/pt_BR.po +17 -47
- odoo/addons/base_report_to_printer/i18n/pt_PT.po +17 -47
- odoo/addons/base_report_to_printer/i18n/sl.po +19 -49
- odoo/addons/base_report_to_printer/i18n/sv.po +19 -64
- odoo/addons/base_report_to_printer/i18n/tr.po +17 -47
- odoo/addons/base_report_to_printer/i18n/zh_CN.po +21 -66
- odoo/addons/base_report_to_printer/models/ir_actions_report.py +6 -5
- odoo/addons/base_report_to_printer/models/printing_action.py +2 -2
- odoo/addons/base_report_to_printer/models/printing_printer.py +1 -1
- odoo/addons/base_report_to_printer/models/printing_report_xml_action.py +1 -1
- odoo/addons/base_report_to_printer/models/res_users.py +11 -3
- odoo/addons/base_report_to_printer/readme/CONTRIBUTORS.md +1 -0
- odoo/addons/base_report_to_printer/readme/CREDITS.md +1 -0
- odoo/addons/base_report_to_printer/static/description/index.html +16 -9
- odoo/addons/base_report_to_printer/static/src/js/qweb_action_manager.esm.js +2 -2
- odoo/addons/base_report_to_printer/tests/test_ir_actions_report.py +121 -86
- odoo/addons/base_report_to_printer/tests/test_printing_job.py +16 -9
- odoo/addons/base_report_to_printer/tests/test_printing_printer.py +50 -34
- odoo/addons/base_report_to_printer/tests/test_printing_printer_tray.py +9 -9
- odoo/addons/base_report_to_printer/tests/test_printing_printer_wizard.py +15 -9
- odoo/addons/base_report_to_printer/tests/test_printing_server.py +38 -27
- odoo/addons/base_report_to_printer/tests/test_report.py +41 -20
- odoo/addons/base_report_to_printer/views/printing_job.xml +2 -2
- odoo/addons/base_report_to_printer/views/printing_printer.xml +3 -3
- odoo/addons/base_report_to_printer/views/printing_report.xml +2 -2
- odoo/addons/base_report_to_printer/views/printing_server.xml +3 -3
- odoo/addons/base_report_to_printer/wizards/print_attachment_report.xml +2 -2
- odoo/addons/base_report_to_printer/wizards/printing_printer_update_wizard.py +1 -1
- {odoo_addon_base_report_to_printer-17.0.1.1.1.dist-info → odoo_addon_base_report_to_printer-18.0.1.0.0.2.dist-info}/METADATA +55 -48
- odoo_addon_base_report_to_printer-18.0.1.0.0.2.dist-info/RECORD +77 -0
- odoo_addon_base_report_to_printer-17.0.1.1.1.dist-info/RECORD +0 -76
- {odoo_addon_base_report_to_printer-17.0.1.1.1.dist-info → odoo_addon_base_report_to_printer-18.0.1.0.0.2.dist-info}/WHEEL +0 -0
- {odoo_addon_base_report_to_printer-17.0.1.1.1.dist-info → odoo_addon_base_report_to_printer-18.0.1.0.0.2.dist-info}/top_level.txt +0 -0
|
@@ -22,7 +22,7 @@ class PrintingReportXmlAction(models.Model):
|
|
|
22
22
|
comodel_name="res.users", string="User", required=True, ondelete="cascade"
|
|
23
23
|
)
|
|
24
24
|
action = fields.Selection(
|
|
25
|
-
selection=lambda s: s.env["printing.action"]._available_action_types
|
|
25
|
+
selection=lambda s: s.env["printing.action"]._available_action_types,
|
|
26
26
|
required=True,
|
|
27
27
|
)
|
|
28
28
|
printer_id = fields.Many2one(comodel_name="printing.printer", string="Printer")
|
|
@@ -11,19 +11,27 @@ from odoo import api, fields, models
|
|
|
11
11
|
class ResUsers(models.Model):
|
|
12
12
|
_inherit = "res.users"
|
|
13
13
|
|
|
14
|
-
@
|
|
14
|
+
@property
|
|
15
15
|
def _user_available_action_types(self):
|
|
16
16
|
return [
|
|
17
17
|
(code, string)
|
|
18
|
-
for code, string in self.env["printing.action"]._available_action_types
|
|
18
|
+
for code, string in self.env["printing.action"]._available_action_types
|
|
19
19
|
if code != "user_default"
|
|
20
20
|
]
|
|
21
21
|
|
|
22
|
-
printing_action = fields.Selection(
|
|
22
|
+
printing_action = fields.Selection(
|
|
23
|
+
selection=lambda self: self._user_available_action_types
|
|
24
|
+
)
|
|
23
25
|
printing_printer_id = fields.Many2one(
|
|
24
26
|
comodel_name="printing.printer", string="Default Printer"
|
|
25
27
|
)
|
|
26
28
|
|
|
29
|
+
@api.constrains("printing_action")
|
|
30
|
+
def _check_printing_action(self):
|
|
31
|
+
for rec in self:
|
|
32
|
+
if rec.printing_action == "user_default":
|
|
33
|
+
raise ValueError("user_default should not be available")
|
|
34
|
+
|
|
27
35
|
@property
|
|
28
36
|
def SELF_READABLE_FIELDS(self):
|
|
29
37
|
return super().SELF_READABLE_FIELDS + ["printing_action", "printing_printer_id"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.
|
|
@@ -367,9 +367,9 @@ ul.auto-toc {
|
|
|
367
367
|
!! This file is generated by oca-gen-addon-readme !!
|
|
368
368
|
!! changes will be overwritten. !!
|
|
369
369
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
370
|
-
!! source digest: sha256:
|
|
370
|
+
!! source digest: sha256:7761acf7bc8cae2f3c56913a0da0ebc3d646ee29311fb4682bde14452b3a69d8
|
|
371
371
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
|
372
|
-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/report-print-send/tree/
|
|
372
|
+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/report-print-send/tree/18.0/base_report_to_printer"><img alt="OCA/report-print-send" src="https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/report-print-send-18-0/report-print-send-18-0-base_report_to_printer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
|
373
373
|
<p>This module allows users to send reports to a printer attached to the
|
|
374
374
|
server.</p>
|
|
375
375
|
<p>It adds an optional behaviour on reports to send it directly to a
|
|
@@ -409,7 +409,8 @@ preprinted paper such as payment slip.</p>
|
|
|
409
409
|
<li><a class="reference internal" href="#credits" id="toc-entry-9">Credits</a><ul>
|
|
410
410
|
<li><a class="reference internal" href="#authors" id="toc-entry-10">Authors</a></li>
|
|
411
411
|
<li><a class="reference internal" href="#contributors" id="toc-entry-11">Contributors</a></li>
|
|
412
|
-
<li><a class="reference internal" href="#
|
|
412
|
+
<li><a class="reference internal" href="#other-credits" id="toc-entry-12">Other credits</a></li>
|
|
413
|
+
<li><a class="reference internal" href="#maintainers" id="toc-entry-13">Maintainers</a></li>
|
|
413
414
|
</ul>
|
|
414
415
|
</li>
|
|
415
416
|
</ul>
|
|
@@ -454,9 +455,9 @@ Printers from CUPS</em></li>
|
|
|
454
455
|
<li>To print a report on a specific printer or tray, you can change
|
|
455
456
|
these in <em>Settings > Printing > Reports</em> to define default
|
|
456
457
|
behaviour.</li>
|
|
457
|
-
<li>To print a report on a specific printer and/or tray for a user,
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
<li>To print a report on a specific printer and/or tray for a user, you
|
|
459
|
+
can change these in <em>Settings > Printing > Reports</em> in <em>Specific
|
|
460
|
+
actions per user</em></li>
|
|
460
461
|
<li>Users may also select a default action, printer or tray in their
|
|
461
462
|
preferences.</li>
|
|
462
463
|
</ul>
|
|
@@ -492,7 +493,7 @@ need to notify the bus or use web_notify for it.</li>
|
|
|
492
493
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/report-print-send/issues">GitHub Issues</a>.
|
|
493
494
|
In case of trouble, please check there if your issue has already been reported.
|
|
494
495
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
|
495
|
-
<a class="reference external" href="https://github.com/OCA/report-print-send/issues/new?body=module:%20base_report_to_printer%0Aversion:%
|
|
496
|
+
<a class="reference external" href="https://github.com/OCA/report-print-send/issues/new?body=module:%20base_report_to_printer%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
|
496
497
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
|
497
498
|
</div>
|
|
498
499
|
<div class="section" id="credits">
|
|
@@ -528,10 +529,16 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|
|
528
529
|
<li>Hughes Damry <<a class="reference external" href="mailto:hughes.damry@acsone.eu">hughes.damry@acsone.eu</a>></li>
|
|
529
530
|
<li>Akim Juillerat <<a class="reference external" href="mailto:akim.juillerat@camptocamp.com">akim.juillerat@camptocamp.com</a>></li>
|
|
530
531
|
<li>Jacques-Etienne Baudoux (BCIM) <<a class="reference external" href="mailto:je@bcim.be">je@bcim.be</a>></li>
|
|
532
|
+
<li>Tris Doan <<a class="reference external" href="mailto:tridm@trobz.com">tridm@trobz.com</a>></li>
|
|
531
533
|
</ul>
|
|
532
534
|
</div>
|
|
535
|
+
<div class="section" id="other-credits">
|
|
536
|
+
<h2><a class="toc-backref" href="#toc-entry-12">Other credits</a></h2>
|
|
537
|
+
<p>The migration of this module from 17.0 to 18.0 was financially supported
|
|
538
|
+
by Camptocamp.</p>
|
|
539
|
+
</div>
|
|
533
540
|
<div class="section" id="maintainers">
|
|
534
|
-
<h2><a class="toc-backref" href="#toc-entry-
|
|
541
|
+
<h2><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h2>
|
|
535
542
|
<p>This module is maintained by the OCA.</p>
|
|
536
543
|
<a class="reference external image-reference" href="https://odoo-community.org">
|
|
537
544
|
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
|
@@ -539,7 +546,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|
|
539
546
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
540
547
|
mission is to support the collaborative development of Odoo features and
|
|
541
548
|
promote its widespread use.</p>
|
|
542
|
-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/report-print-send/tree/
|
|
549
|
+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/report-print-send/tree/18.0/base_report_to_printer">OCA/report-print-send</a> project on GitHub.</p>
|
|
543
550
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
|
544
551
|
</div>
|
|
545
552
|
</div>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/** @odoo-module */
|
|
2
|
-
import {_t} from "@web/core/l10n/translation";
|
|
3
1
|
import {markup} from "@odoo/owl";
|
|
2
|
+
import {_t} from "@web/core/l10n/translation";
|
|
4
3
|
import {registry} from "@web/core/registry";
|
|
5
4
|
|
|
6
5
|
async function cupsReportActionHandler(action, options, env) {
|
|
@@ -52,6 +51,7 @@ async function cupsReportActionHandler(action, options, env) {
|
|
|
52
51
|
title: `${terms.issue_on} ${print_action.printer_name}`,
|
|
53
52
|
type: "warning",
|
|
54
53
|
sticky: true,
|
|
54
|
+
messageIsHtml: true,
|
|
55
55
|
buttons: [
|
|
56
56
|
{
|
|
57
57
|
name: _t("Print"),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Copyright 2016 SYLEAM
|
|
3
3
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
4
4
|
|
|
5
|
+
import logging
|
|
5
6
|
from unittest import mock
|
|
6
7
|
|
|
7
8
|
from odoo.tests.common import TransactionCase
|
|
@@ -57,14 +58,14 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
57
58
|
|
|
58
59
|
def test_print_action_for_report_name_gets_report(self):
|
|
59
60
|
"""It should get report by name"""
|
|
60
|
-
with mock.patch("
|
|
61
|
+
with mock.patch(f"{model}._get_report_from_name") as mk:
|
|
61
62
|
expect = "test"
|
|
62
63
|
self.Model.print_action_for_report_name(expect)
|
|
63
64
|
mk.assert_called_once_with(expect)
|
|
64
65
|
|
|
65
66
|
def test_print_action_for_report_name_returns_if_no_report(self):
|
|
66
67
|
"""It should return empty dict when no matching report"""
|
|
67
|
-
with mock.patch("
|
|
68
|
+
with mock.patch(f"{model}._get_report_from_name") as mk:
|
|
68
69
|
expect = "test"
|
|
69
70
|
mk.return_value = False
|
|
70
71
|
res = self.Model.print_action_for_report_name(expect)
|
|
@@ -72,7 +73,7 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
72
73
|
|
|
73
74
|
def test_print_action_for_report_name_returns_if_report(self):
|
|
74
75
|
"""It should return correct serializable result for behaviour"""
|
|
75
|
-
with mock.patch("
|
|
76
|
+
with mock.patch(f"{model}._get_report_from_name") as mk:
|
|
76
77
|
res = self.Model.print_action_for_report_name("test")
|
|
77
78
|
behaviour = mk().behaviour()
|
|
78
79
|
expect = {
|
|
@@ -102,14 +103,19 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
102
103
|
report = self.Model.search([], limit=1)
|
|
103
104
|
self.env.user.printing_action = "client"
|
|
104
105
|
self.env.user.printing_printer_id = self.new_printer()
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
with (
|
|
107
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
108
|
+
):
|
|
109
|
+
self.assertEqual(
|
|
110
|
+
report.behaviour(),
|
|
111
|
+
{
|
|
112
|
+
"action": "client",
|
|
113
|
+
"printer": self.env.user.printing_printer_id,
|
|
114
|
+
"tray": False,
|
|
115
|
+
},
|
|
116
|
+
)
|
|
117
|
+
self.assertEqual(len(logs.records), 1)
|
|
118
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
113
119
|
|
|
114
120
|
def test_behaviour_report_values(self):
|
|
115
121
|
"""It should return the action and printer from report"""
|
|
@@ -117,14 +123,19 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
117
123
|
self.env.user.printing_action = "client"
|
|
118
124
|
report.property_printing_action_id = self.new_action()
|
|
119
125
|
report.printing_printer_id = self.new_printer()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
with (
|
|
127
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
128
|
+
):
|
|
129
|
+
self.assertEqual(
|
|
130
|
+
report.behaviour(),
|
|
131
|
+
{
|
|
132
|
+
"action": report.property_printing_action_id.action_type,
|
|
133
|
+
"printer": report.printing_printer_id,
|
|
134
|
+
"tray": False,
|
|
135
|
+
},
|
|
136
|
+
)
|
|
137
|
+
self.assertEqual(len(logs.records), 1)
|
|
138
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
128
139
|
|
|
129
140
|
def test_behaviour_user_action(self):
|
|
130
141
|
"""It should return the action and printer from user action"""
|
|
@@ -188,14 +199,19 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
188
199
|
printing_action = self.new_printing_action()
|
|
189
200
|
printing_action.user_id = self.env.user
|
|
190
201
|
printing_action.printer_id = self.new_printer()
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
with (
|
|
203
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
204
|
+
):
|
|
205
|
+
self.assertEqual(
|
|
206
|
+
report.behaviour(),
|
|
207
|
+
{
|
|
208
|
+
"action": printing_action.action,
|
|
209
|
+
"printer": printing_action.printer_id,
|
|
210
|
+
"tray": False,
|
|
211
|
+
},
|
|
212
|
+
)
|
|
213
|
+
self.assertEqual(len(logs.records), 1)
|
|
214
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
199
215
|
|
|
200
216
|
def test_behaviour_printing_action_user_defaults(self):
|
|
201
217
|
"""It should return the action and printer from user with printing
|
|
@@ -215,57 +231,71 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
215
231
|
"""
|
|
216
232
|
It should return the correct tray
|
|
217
233
|
"""
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
234
|
+
with (
|
|
235
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
236
|
+
):
|
|
237
|
+
report = self.Model.search([], limit=1)
|
|
238
|
+
action = self.env["printing.report.xml.action"].create(
|
|
239
|
+
{
|
|
240
|
+
"user_id": self.env.user.id,
|
|
241
|
+
"report_id": report.id,
|
|
242
|
+
"action": "server",
|
|
243
|
+
}
|
|
244
|
+
)
|
|
245
|
+
printer = self.new_printer()
|
|
246
|
+
tray_vals = {
|
|
247
|
+
"name": "Tray",
|
|
248
|
+
"system_name": "Tray",
|
|
249
|
+
"printer_id": printer.id,
|
|
250
|
+
}
|
|
251
|
+
user_tray = self.new_tray({"system_name": "User tray"}, tray_vals)
|
|
252
|
+
report_tray = self.new_tray({"system_name": "Report tray"}, tray_vals)
|
|
253
|
+
action_tray = self.new_tray({"system_name": "Action tray"}, tray_vals)
|
|
254
|
+
|
|
255
|
+
# No report passed
|
|
256
|
+
self.env.user.printer_tray_id = False
|
|
257
|
+
options = printer.print_options()
|
|
258
|
+
self.assertFalse("InputSlot" in options)
|
|
259
|
+
|
|
260
|
+
# No tray defined
|
|
261
|
+
self.env.user.printer_tray_id = False
|
|
262
|
+
report.printer_tray_id = False
|
|
263
|
+
action.printer_tray_id = False
|
|
264
|
+
options = report.behaviour()
|
|
265
|
+
self.assertTrue("tray" in options)
|
|
266
|
+
|
|
267
|
+
# Only user tray is defined
|
|
268
|
+
self.env.user.printer_tray_id = user_tray
|
|
269
|
+
report.printer_tray_id = False
|
|
270
|
+
action.printer_tray_id = False
|
|
271
|
+
self.assertEqual("User tray", report.behaviour()["tray"])
|
|
272
|
+
|
|
273
|
+
# Only report tray is defined
|
|
274
|
+
self.env.user.printer_tray_id = False
|
|
275
|
+
report.printer_tray_id = report_tray
|
|
276
|
+
action.printer_tray_id = False
|
|
277
|
+
self.assertEqual("Report tray", report.behaviour()["tray"])
|
|
278
|
+
|
|
279
|
+
# Only action tray is defined
|
|
280
|
+
self.env.user.printer_tray_id = False
|
|
281
|
+
report.printer_tray_id = False
|
|
282
|
+
action.printer_tray_id = action_tray
|
|
283
|
+
self.assertEqual("Action tray", report.behaviour()["tray"])
|
|
284
|
+
|
|
285
|
+
# User and report tray defined
|
|
286
|
+
self.env.user.printer_tray_id = user_tray
|
|
287
|
+
report.printer_tray_id = report_tray
|
|
288
|
+
action.printer_tray_id = False
|
|
289
|
+
self.assertEqual("Report tray", report.behaviour()["tray"])
|
|
290
|
+
|
|
291
|
+
# All trays are defined
|
|
292
|
+
self.env.user.printer_tray_id = user_tray
|
|
293
|
+
report.printer_tray_id = report_tray
|
|
294
|
+
action.printer_tray_id = action_tray
|
|
295
|
+
self.assertEqual("Action tray", report.behaviour()["tray"])
|
|
296
|
+
self.assertEqual(len(logs.records), 6)
|
|
297
|
+
for record in logs.records:
|
|
298
|
+
self.assertEqual(record.levelno, logging.WARNING)
|
|
269
299
|
|
|
270
300
|
def test_onchange_printer_tray_id_empty(self):
|
|
271
301
|
action = self.Model.new({"printer_tray_id": False})
|
|
@@ -305,11 +335,16 @@ class TestIrActionsReportXml(TransactionCase):
|
|
|
305
335
|
printing_action.user_id = self.env.user
|
|
306
336
|
printing_action.printer_id = self.new_printer()
|
|
307
337
|
printing_action.printer_id.multi_thread = True
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
338
|
+
with (
|
|
339
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
340
|
+
):
|
|
341
|
+
self.assertEqual(
|
|
342
|
+
report.behaviour(),
|
|
343
|
+
{
|
|
344
|
+
"action": printing_action.action,
|
|
345
|
+
"printer": printing_action.printer_id,
|
|
346
|
+
"tray": False,
|
|
347
|
+
},
|
|
348
|
+
)
|
|
349
|
+
self.assertEqual(len(logs.records), 1)
|
|
350
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Copyright 2016 LasLabs Inc.
|
|
2
2
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
3
3
|
|
|
4
|
+
import logging
|
|
4
5
|
from unittest import mock
|
|
5
6
|
|
|
6
7
|
from odoo import fields
|
|
@@ -42,17 +43,23 @@ class TestPrintingJob(TransactionCase):
|
|
|
42
43
|
values["printer_id"] = printer.id
|
|
43
44
|
return self.env["printing.job"].create(values)
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
def test_cancel_job_error(self, cups):
|
|
46
|
+
def test_cancel_job_error(self):
|
|
47
47
|
"""It should catch any exception from CUPS and update status"""
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
with (
|
|
49
|
+
mock.patch(f"{model}.cups") as cups,
|
|
50
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
51
|
+
):
|
|
52
|
+
cups.Connection.side_effect = Exception
|
|
53
|
+
printer = self.new_printer()
|
|
54
|
+
job = self.new_job(printer, {"job_id_cups": 2})
|
|
55
|
+
job.action_cancel()
|
|
56
|
+
cups.Connection.side_effect = None
|
|
57
|
+
self.assertEqual(cups.Connection().cancelJob.call_count, 0)
|
|
58
|
+
|
|
59
|
+
self.assertEqual(len(logs.records), 3)
|
|
60
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
54
61
|
|
|
55
|
-
@mock.patch("
|
|
62
|
+
@mock.patch(f"{model}.cups")
|
|
56
63
|
def test_cancel_job(self, cups):
|
|
57
64
|
"""It should catch any exception from CUPS and update status"""
|
|
58
65
|
printer = self.new_printer()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Copyright 2016 LasLabs Inc.
|
|
2
2
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
3
3
|
|
|
4
|
+
import logging
|
|
4
5
|
import tempfile
|
|
5
6
|
from unittest import mock
|
|
6
7
|
|
|
@@ -79,11 +80,11 @@ class TestPrintingPrinter(TransactionCase):
|
|
|
79
80
|
)
|
|
80
81
|
self.assertTrue("InputSlot" in self.Model.print_options(report, tray="Test"))
|
|
81
82
|
|
|
82
|
-
@mock.patch("
|
|
83
|
+
@mock.patch(f"{server_model}.cups")
|
|
83
84
|
def test_print_report(self, cups):
|
|
84
85
|
"""It should print a report through CUPS"""
|
|
85
86
|
fd, file_name = tempfile.mkstemp()
|
|
86
|
-
with mock.patch("
|
|
87
|
+
with mock.patch(f"{model}.mkstemp") as mkstemp:
|
|
87
88
|
mkstemp.return_value = fd, file_name
|
|
88
89
|
printer = self.new_record()
|
|
89
90
|
printer.print_document(self.report, b"content to print", doc_format="pdf")
|
|
@@ -91,37 +92,52 @@ class TestPrintingPrinter(TransactionCase):
|
|
|
91
92
|
printer.system_name, file_name, file_name, options={}
|
|
92
93
|
)
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
def test_print_report_error(self, cups):
|
|
95
|
+
def test_print_report_error(self):
|
|
96
96
|
"""It should print a report through CUPS"""
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
with (
|
|
98
|
+
mock.patch(f"{model}.cups") as cups,
|
|
99
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
100
|
+
):
|
|
101
|
+
cups.Connection.side_effect = Exception
|
|
102
|
+
fd, file_name = tempfile.mkstemp()
|
|
103
|
+
with mock.patch(f"{model}.mkstemp") as mkstemp:
|
|
104
|
+
mkstemp.return_value = fd, file_name
|
|
105
|
+
printer = self.new_record()
|
|
106
|
+
with self.assertRaises(UserError):
|
|
107
|
+
printer.print_document(
|
|
108
|
+
self.report, b"content to print", doc_format="pdf"
|
|
109
|
+
)
|
|
110
|
+
self.assertEqual(len(logs.records), 1)
|
|
111
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
112
|
+
|
|
113
|
+
def test_print_file(self):
|
|
109
114
|
"""It should print a file through CUPS"""
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
with (
|
|
116
|
+
mock.patch(f"{server_model}.cups") as cups,
|
|
117
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
118
|
+
):
|
|
119
|
+
file_name = "file_name"
|
|
120
|
+
printer = self.new_record()
|
|
121
|
+
printer.print_file(file_name, "pdf")
|
|
122
|
+
cups.Connection().printFile.assert_called_once_with(
|
|
123
|
+
printer.system_name, file_name, file_name, options={}
|
|
124
|
+
)
|
|
125
|
+
self.assertEqual(len(logs.records), 1)
|
|
126
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
116
127
|
|
|
117
|
-
|
|
118
|
-
def test_print_file_error(self, cups):
|
|
128
|
+
def test_print_file_error(self):
|
|
119
129
|
"""It should print a file through CUPS"""
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
with (
|
|
131
|
+
mock.patch(f"{server_model}.cups") as cups,
|
|
132
|
+
self.assertLogs(level=logging.WARNING) as logs,
|
|
133
|
+
):
|
|
134
|
+
cups.Connection.side_effect = Exception
|
|
135
|
+
file_name = "file_name"
|
|
136
|
+
printer = self.new_record()
|
|
137
|
+
with self.assertRaises(UserError):
|
|
138
|
+
printer.print_file(file_name)
|
|
139
|
+
self.assertEqual(len(logs.records), 1)
|
|
140
|
+
self.assertEqual(logs.records[0].levelno, logging.WARNING)
|
|
125
141
|
|
|
126
142
|
def test_set_default(self):
|
|
127
143
|
"""It should set a single record as default"""
|
|
@@ -142,7 +158,7 @@ class TestPrintingPrinter(TransactionCase):
|
|
|
142
158
|
printer.unset_default()
|
|
143
159
|
self.assertFalse(printer.default)
|
|
144
160
|
|
|
145
|
-
@mock.patch("
|
|
161
|
+
@mock.patch(f"{server_model}.cups")
|
|
146
162
|
def test_cancel_all_jobs(self, cups):
|
|
147
163
|
"""It should cancel all jobs"""
|
|
148
164
|
printer = self.new_record()
|
|
@@ -151,7 +167,7 @@ class TestPrintingPrinter(TransactionCase):
|
|
|
151
167
|
name=printer.system_name, purge_jobs=False
|
|
152
168
|
)
|
|
153
169
|
|
|
154
|
-
@mock.patch("
|
|
170
|
+
@mock.patch(f"{server_model}.cups")
|
|
155
171
|
def test_cancel_and_purge_all_jobs(self, cups):
|
|
156
172
|
"""It should cancel all jobs"""
|
|
157
173
|
printer = self.new_record()
|
|
@@ -160,21 +176,21 @@ class TestPrintingPrinter(TransactionCase):
|
|
|
160
176
|
name=printer.system_name, purge_jobs=True
|
|
161
177
|
)
|
|
162
178
|
|
|
163
|
-
@mock.patch("
|
|
179
|
+
@mock.patch(f"{server_model}.cups")
|
|
164
180
|
def test_enable_printer(self, cups):
|
|
165
181
|
"""It should enable the printer"""
|
|
166
182
|
printer = self.new_record()
|
|
167
183
|
printer.enable()
|
|
168
184
|
cups.Connection().enablePrinter.assert_called_once_with(printer.system_name)
|
|
169
185
|
|
|
170
|
-
@mock.patch("
|
|
186
|
+
@mock.patch(f"{server_model}.cups")
|
|
171
187
|
def test_disable_printer(self, cups):
|
|
172
188
|
"""It should disable the printer"""
|
|
173
189
|
printer = self.new_record()
|
|
174
190
|
printer.disable()
|
|
175
191
|
cups.Connection().disablePrinter.assert_called_once_with(printer.system_name)
|
|
176
192
|
|
|
177
|
-
@mock.patch("
|
|
193
|
+
@mock.patch(f"{server_model}.cups")
|
|
178
194
|
def test_print_test_page(self, cups):
|
|
179
195
|
"""It should print a test page"""
|
|
180
196
|
printer = self.new_record()
|