diff --git a/__manifest__.py b/__manifest__.py
index abd6dcea685608e1605113df9f781ab6c4abfcba..1eba130d5b3af78ce501d415a9a1a2f6aa52d8e4 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -1,7 +1,7 @@
{
"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"],
diff --git a/static/src/js/container.js b/static/src/js/container.js
index 5c09bcc9bc19fb030481fd586f9554c7509668ea..4bcad531a915e820a5f5768cdd4426ddcabc79c2 100644
--- a/static/src/js/container.js
+++ b/static/src/js/container.js
@@ -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);
-
- return {
+ //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());
-
this.pos.proxy.print_receipt(receipt);
+
+
},
print: function() {
var self = this;
diff --git a/static/src/xml/pos.xml b/static/src/xml/pos.xml
index c755f16b295a2cd0dcf6b94980cf966f29bacbd5..85d803bc607f7c1cc2df706c2da184d8ed01467e 100644
--- a/static/src/xml/pos.xml
+++ b/static/src/xml/pos.xml
@@ -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"/>";
-
- var qrcode = new QRCode('qrcode' , {
- text: qr_data,
- width: 160,
- height: 160,
- colorDark : "#000000",
- colorLight : "#ffffff",
- correctLevel : QRCode.CorrectLevel.H
- });
- qrcode.makeCode(qr_data);
-
- $("#qrcode > img").css({"margin":"20px auto"});
- </script>
+
+ <div>
+ <p>l'image se trouve la</p>
+
+ <img t-att-src="url_barcode" />
+ </div>
+ <div class='receipt-total'>
+ <h1>TEST</h1>
+ <div>
+ <t t-esc="id_container"/>
+ </div>
+ <div class="pos-right-align">
+ <t t-esc="weight"/>
</div>
</div>
- <table class='receipt-total'>
- <tr>
- <td><t t-esc="id_container"/></td>
- <td class="pos-right-align">
- <t t-esc="weight"/>
- </td>
- </tr>
- </table>
</div>
- </receipt>
+ </receipt> -->
</t>
</templates>