Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Converter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
Converter
Merge requests
!69
Add qrcode converter
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add qrcode converter
topic/18.0/qrcode
into
branch/18.0
Overview
5
Commits
3
Pipelines
0
Changes
9
All threads resolved!
Hide all comments
Merged
Axel Prel
requested to merge
topic/18.0/qrcode
into
branch/18.0
2 weeks ago
Overview
5
Commits
3
Pipelines
0
Changes
4
All threads resolved!
Hide all comments
Expand
0
0
Merge request reports
Compare
version 1
version 4
818e050d
2 weeks ago
version 3
300e2778
2 weeks ago
version 2
8984716b
2 weeks ago
version 1
4467baa6
2 weeks ago
branch/18.0 (base)
and
version 2
latest version
9a2413fc
3 commits,
2 weeks ago
version 4
818e050d
5 commits,
2 weeks ago
version 3
300e2778
5 commits,
2 weeks ago
version 2
8984716b
5 commits,
2 weeks ago
version 1
4467baa6
5 commits,
2 weeks ago
Show latest version
4 files
+
16
−
23
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
tests/test_qr_code.py
0 → 100644
+
62
−
0
Options
##############################################################################
#
# Converter Odoo module
# Copyright © 2025 XCG Consulting <https://xcg-consulting.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from
unittest
import
skipUnless
from
odoo
import
tests
# type: ignore[import-untyped]
from
..
import
QRCodeDataURL
,
QRCodeFile
,
stringToQRCode
@skipUnless
(
tests
.
can_import
(
"
qrcode
"
),
"
qrcode module not available
"
)
class
TestQRCode
(
tests
.
TransactionCase
):
def
setUp
(
self
):
super
().
setUp
()
self
.
ready_mat
=
self
.
env
[
"
res.partner
"
].
search
(
[(
"
name
"
,
"
=
"
,
"
Ready Mat
"
)],
limit
=
1
)
def
test_print_qr_code_1
(
self
):
qr
=
stringToQRCode
(
"
https://google.com
"
)
qr
.
print_ascii
()
def
test_string_to_qr_code_2
(
self
):
qr
=
stringToQRCode
(
self
.
ready_mat
.
website
)
qr
.
print_ascii
()
def
test_qr_code_file
(
self
):
converter
=
QRCodeFile
(
"
website
"
)
img
=
converter
.
odoo_to_message
(
self
.
ready_mat
)
self
.
assertEqual
(
"
image/png
"
,
img
[
"
mime-type
"
])
self
.
assertRegex
(
img
[
"
body
"
],
r
"
[A-Za-z0-9+/=]+$
"
,
"
The generated base64 body is incorrect
"
,
)
def
test_qr_code_data_url
(
self
):
converter
=
QRCodeDataURL
(
"
website
"
)
url
=
converter
.
odoo_to_message
(
self
.
ready_mat
)
self
.
assertRegex
(
url
,
r
"
^data:image/png;base64,[A-Za-z0-9+/=]+$
"
,
"
The generated Data URL is not correctly formatted
"
,
)
Loading