From b021279a0b3c70bfa81c2ca78d6e28266e476075 Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Wed, 30 Mar 2022 15:45:43 +0200
Subject: [PATCH] [ADD]Add nomenclature to the table container

---
 __manifest__.py            |  2 +-
 static/src/js/container.js | 19 ++++++++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/__manifest__.py b/__manifest__.py
index 6576bcf..b08b976 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.1.7.0",
+    "version": "12.0.1.8.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 8dc3cee..9cb6e15 100644
--- a/static/src/js/container.js
+++ b/static/src/js/container.js
@@ -29,7 +29,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
 
         init: function(parent, options){
             this._super(parent, options);
-            this.barcode_base64;
+            this.barcode_base64 = false;
         },
 
         show: function(){
@@ -54,7 +54,6 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
                     else {
                         count_it = 0;
                         if (self.weight > 0){
-                            self.create_container();
                             self.print();
                             self.gui.show_screen('confirmation');
                         }
@@ -91,7 +90,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
         /////////////////////////////
 
         handle_auto_print: function() {
-            this.create_container();
+            // this.create_container();
             this.print();
             this.click_next();
         },
@@ -112,7 +111,6 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             var categ_container = this.pos.config.categ_container;
             var timestamp = Math.floor((new Date().getTime())/1000);
 
-//            var weight_str = (this.weight * 1000).toString();
             var weight_str = parseInt(this.weight * 1000, 10);
             weight_str = ("0000" + weight_str).slice(-4);
 
@@ -130,12 +128,14 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             var second_int = parseInt(ean20.substring(10,21));
             var cle_int = parseInt(ean20.substr(-1));
 
-//            Conversion bae 36
+//            Conversion base 36
             var base36_first = first_int.toString(36);
             var base36_second = second_int.toString(36);
             var base36_cle = cle_int.toString(36);
 
-            var url_qrcode = url_qr.concat(base36_cle,'-',base36_first,'-',base36_second);
+            this.barcode_base64 = base36_cle.concat('-',base36_first,'-',base36_second);
+            var url_qrcode = url_qr.concat(this.barcode_base64);
+            
             var weight_gr = parseInt(weight_str, 10) + 'g'
             return {    
                 widget: this,
@@ -151,7 +151,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             this._super();
             
             this.$('.next,.print-qrcode').click(function(){
-                self.create_container();
+                // self.create_container();
                 self.print();
             });
         },
@@ -177,8 +177,8 @@ 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.create_container();
             this.pos.proxy.print_receipt(receipt);
-
             
         },
         print: function() {
@@ -206,6 +206,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
         },
         render_receipt: function() {
             this.$('.pos-qr-container').html(QWeb.render('PosQR', this.get_receipt_render_env()));
+            this.create_container();
         },
         create_container: function(){
             var self = this;
@@ -213,7 +214,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
 
             fields['weight'] = this.weight;
 
-            fields.barcode = false;
+            fields.barcode = this.barcode_base64;
             fields.name = _t('Container');
 
 			this.pos.push_container(fields);
-- 
GitLab