Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
V
vracoop_pos_container_qrcode
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Le Filament
Vracoop
vracoop_pos_container_qrcode
Validations
4d3a490e
Valider
4d3a490e
rédigé
18 janv. 2022
par
Juliana
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[ADD] Add print QR code + new template
parent
0a097746
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
__manifest__.py
+1
-1
1 ajout, 1 suppression
__manifest__.py
static/src/js/container.js
+95
-12
95 ajouts, 12 suppressions
static/src/js/container.js
static/src/xml/pos.xml
+67
-37
67 ajouts, 37 suppressions
static/src/xml/pos.xml
avec
163 ajouts
et
50 suppressions
__manifest__.py
+
1
−
1
Voir le fichier @
4d3a490e
{
"
name
"
:
"
VRACOOP - POS Balance Container QRCode
"
,
"
summary
"
:
"
VRACOOP - POS Balance Container QRCode
"
,
"
version
"
:
"
12.0.
0.2.2
"
,
"
version
"
:
"
12.0.
1.0.0
"
,
"
development_status
"
:
"
Beta
"
,
"
author
"
:
"
Le Filament
"
,
"
maintainers
"
:
[
"
remi-filament
"
],
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
static/src/js/container.js
+
95
−
12
Voir le fichier @
4d3a490e
...
...
@@ -29,6 +29,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
init
:
function
(
parent
,
options
){
this
.
_super
(
parent
,
options
);
this
.
barcode_base64
;
},
show
:
function
(){
...
...
@@ -58,12 +59,6 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
var
self
=
this
;
this
.
$
(
'
.next,.add-container
'
).
click
(
function
(){
self
.
render_receipt
();
self
.
handle_auto_print
();
self
.
renderElement
();
});
if
(
this
.
pos
.
config
.
iface_vkeyboard
&&
this
.
chrome
.
widget
.
keyboard
){
this
.
chrome
.
widget
.
keyboard
.
connect
(
$
(
this
.
el
.
querySelector
(
'
.container-name input
'
)));
}
...
...
@@ -72,9 +67,12 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
$
(
"
#pos-topheader-scale-cont
"
).
removeClass
(
'
oe_hidden
'
);
setTimeout
(
function
(){
self
.
set_weight
(
0
);
},
5000
);
if
(
this
..
weight
!==
0
)
{
self
.
print
();
}
},
2000
);
this
.
render_receipt
();
},
hide
:
function
(){
...
...
@@ -120,13 +118,96 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
var
code_base36
=
ean20_int
.
toString
(
36
);
var
url_qrcode
=
url_qr
.
concat
(
code_base36
);
//var logo = this.pos.company_logo_base64;
//var url_barcode = window.location.origin + "/report/barcode/?type=EAN13&value=0492525252525&width=300&height=80"
// ****************************************
// Impression barcode
var
barcode
=
new
Image
();
barcode
.
crossOrigin
=
"
anonymous
"
;
var
barcode_base64
=
window
.
location
.
origin
+
"
/report/barcode/?type=EAN13&value=0492525252525&width=300&height=80
"
//barcode.src = window.location.origin + "/report/barcode/?type=QR&value=" + url_qrcode + "&width=200&height=200"
// var img = barcode;
// var ratio = 1;
// var targetwidth = 200;
// var maxheight = 200;
// if( img.width !== targetwidth ){
// ratio = targetwidth / img.width;
// }
// if( img.height * ratio > maxheight ){
// ratio = maxheight / img.height;
// }
// var width = Math.floor(img.width * ratio);
// var height = Math.floor(img.height * ratio);
// var c = document.createElement('canvas');
// c.width = width;
// c.height = height;
// var ctx = c.getContext('2d');
// ctx.drawImage(barcode,0,0, width, height);
// var barcode_base64 = c.toDataURL('image/png');
// Fin impression barcode
// **************************************
return
{
widget
:
this
,
weight
:
this
.
weight
,
url_qrcode
:
url_qrcode
,
id_container
:
code_base36
id_container
:
code_base36
,
url_barcode
:
url_qrcode
,
}
},
_convert_qr_img_to_base64
:
function
()
{
var
mag_name
=
this
.
pos
.
config
.
mag_id
;
var
url_qr
=
this
.
pos
.
config
.
url_qrcode
;
var
prefixe_qr
=
this
.
pos
.
config
.
prefixe_qr
.
toString
();
var
timestamp
=
Math
.
floor
((
new
Date
().
getTime
())
/
1000
);
var
weight_str
=
(
this
.
weight
*
1000
).
toString
();
var
weight_str
=
(
0.2
*
1000
).
toString
();
weight_str
=
(
"
0000
"
+
weight_str
).
slice
(
-
4
);
var
ean19
=
''
;
ean19
=
ean19
.
concat
(
prefixe_qr
,
timestamp
.
toString
(),
weight_str
);
var
ean20
=
this
.
pos
.
barcode_reader
.
barcode_parser
.
sanitize_ean19
(
ean19
);
var
ean20_int
=
parseInt
(
ean20
);
var
code_base36
=
ean20_int
.
toString
(
36
);
var
url_qrcode
=
url_qr
.
concat
(
code_base36
);
var
deferred
=
new
$
.
Deferred
();
var
img
=
new
Image
();
img
.
onload
=
function
()
{
var
canvas
=
document
.
createElement
(
'
CANVAS
'
);
var
ctx
=
canvas
.
getContext
(
'
2d
'
);
canvas
.
height
=
200
;
canvas
.
width
=
200
;
ctx
.
drawImage
(
img
,
0
,
0
);
var
dataURL
=
canvas
.
toDataURL
(
'
image/jpeg
'
);
this
.
barcode_base64
=
dataURL
;
canvas
=
null
;
deferred
.
resolve
();
};
img
.
crossOrigin
=
'
use-credentials
'
;
img
.
src
=
window
.
location
.
origin
+
"
/report/barcode/?type=QR&value=
"
+
url_qrcode
+
"
&width=200&height=200
"
;
return
deferred
;
},
renderElement
:
function
()
{
var
self
=
this
;
this
.
_super
();
this
.
$
(
'
.next,.add-container
'
).
click
(
function
(){
self
.
print
();
});
},
print_web
:
function
()
{
...
...
@@ -148,9 +229,11 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
}
},
print_xml
:
function
()
{
var
receipt
=
QWeb
.
render
(
'
XmlQR
'
,
this
.
get_receipt_render_env
());
var
receipt
=
QWeb
.
render
(
'
XmlQR
'
,
this
.
get_receipt_render_env
());
this
.
pos
.
proxy
.
print_receipt
(
receipt
);
},
print
:
function
()
{
var
self
=
this
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
static/src/xml/pos.xml
+
67
−
37
Voir le fichier @
4d3a490e
...
...
@@ -80,10 +80,25 @@
</div>
</t>
<t
t-name=
"PosQR"
>
<!-- OLD CODE -->
<!-- <t t-name="PosQR">
<div class="pos-sale-ticket">
<div class="pos-center-align">
<img t-att-src="widget.pos.company_logo_base64"/><br />
<div class='receipt-total'>
<div>
<t t-esc="id_container"/>
</div>
<div class="pos-right-align">
<t t-esc="weight"/>
</div>
</div>
<div>
<p>l'image se trouve la</p>
<img t-att-src="url_barcode" style="width:100%;height:35%;" />
</div>
</div>
<div class="einv-qr">
<div t-attf-id="qrcode_container">
...
...
@@ -102,59 +117,74 @@
});
qrcode.makeCode(qr_data);
$("#qrcode > img").css({"margin":"20px auto"});
</script>
</div>
</div>
<table
class=
'receipt-total'
>
<tr>
<td><t
t-esc=
"id_container"
/></td>
<td
class=
"pos-right-align"
>
</div>
</t> -->
<!-- OLD CODE -->
<!-- NEW CODE -->
<t
t-name=
"PosQR"
>
<div
class=
"pos-sale-ticket"
>
<div
class=
"pos-center-align"
>
<img
t-att-src=
"widget.pos.company_logo_base64"
/><br
/>
<div
class=
'receipt-total'
>
<div>
<t
t-esc=
"id_container"
/>
</div>
<div
class=
"pos-right-align"
>
<t
t-esc=
"weight"
/>
</td>
</tr>
</table>
</div>
</div>
<div>
<p>
l'image se trouve la
</p>
<img
t-att-src=
"url_barcode"
/>
</div>
</div>
</div>
</t>
<!-- NEW CODE -->
<t
t-name=
"XmlQR"
>
<receipt
align=
'center'
width=
'40'
value-thousands-separator=
''
>
^XA
^FX Third section with bar code.
^BY3,2,10
^FO60,10^BQ,2,3,H,7^FDQA,
<t
t-esc=
'url_barcode'
/>
^FS
^XZ
</receipt>
<!-- <receipt align='center' width='40' value-thousands-separator='' >
<div class="pos-sale-ticket">
<div class="pos-center-align">
<img t-att-src="widget.pos.company_logo_base64"/><br />
</div>
<div
class=
"einv-qr"
>
<div
t-attf-id=
"qrcode_container"
>
<div
id=
"qrcode"
></div>
<script
type=
"text/javascript"
>
var qr_data ="
<t
t-esc=
"url_qrcode"
/>
";
</div>
var qrcode = new QRCode('qrcode' , {
text: qr_data,
width: 160,
height: 160,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
qrcode.makeCode(qr_data);
<div>
<p>l'image se trouve la</p>
$("#qrcode > img").css({"margin":"20px auto"});
</script>
<img t-att-src="url_barcode" />
</div>
<div class='receipt-total'>
<h1>TEST</h1>
<div>
<t t-esc="id_container"/>
</div>
<table
class=
'receipt-total'
>
<tr>
<td><t
t-esc=
"id_container"
/></td>
<td
class=
"pos-right-align"
>
<div class="pos-right-align">
<t t-esc="weight"/>
</td>
</tr>
</table>
</div>
</div>
</div>
</receipt>
</receipt>
-->
</t>
</templates>
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter