From b6a8d2fe747bfb71dbca0a22c153312b78bdade1 Mon Sep 17 00:00:00 2001 From: Juliana Date: Thu, 14 Sep 2023 15:43:01 +0200 Subject: [PATCH] [FIX]Check weight 0 to create transaction --- models/pos_order_line.py | 81 ++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/models/pos_order_line.py b/models/pos_order_line.py index 129141f..56e165b 100644 --- a/models/pos_order_line.py +++ b/models/pos_order_line.py @@ -38,46 +38,47 @@ class PosOrderLine(models.Model): if res.container_id: today = datetime.today().isoformat('T')[:19] - weight_str = str(int(res.qty * 1000)) - # weight_str = str(res.qty * 1000).zfill(5) - - if res.product_id.default_code: - prod = (res.product_id.default_code).zfill(5) - else: - prod = "12345" - - ean13 = "26" + prod + weight_str.zfill(5) + "4" - - weight_brut_str = str(int((res.container_weight + res.qty) * 1000)) - - ean13_verif = "2600999" + weight_brut_str.zfill(5) + "4" - - seller_id = self.env['product.supplierinfo'].search([ - ("product_tmpl_id", '=', res.product_id.product_tmpl_id.id)], - limit=1) - - nomenclature = self.env['barcode.nomenclature'].browse(1) - ean13_digit = nomenclature.sanitize_ean(ean13) - ean13_verif_digit = nomenclature.sanitize_ean(ean13_verif) - - vals = { - "date_iso": today, - 'qrcode': 'https://qr.mayam.fr/' + str(res.container_id.barcode), - "container_ean13": res.container_id.barcode, - "product_id": res.product_id.id, - "name": res.product_id.name, - "price_net": res.price_subtotal, - "price_product": res.price_unit, - "weight_net": res.qty, - "weight_tare": res.container_weight, - "seller_name": seller_id.name.name, - "seller_code": seller_id.product_code, - "ean13": ean13_digit, - "ean13_verif": ean13_verif_digit, - "is_pos": True, - "balance_id": res.caisse_id - } - self.env['pos.transaction'].create(vals) + if res.qty > 0: + weight_str = str(int(res.qty * 1000)) + # weight_str = str(res.qty * 1000).zfill(5) + + if res.product_id.default_code: + prod = (res.product_id.default_code).zfill(5) + else: + prod = "12345" + + ean13 = "26" + prod + weight_str.zfill(5) + "4" + + weight_brut_str = str(int((res.container_weight + res.qty) * 1000)) + + ean13_verif = "2600999" + weight_brut_str.zfill(5) + "4" + + seller_id = self.env['product.supplierinfo'].search([ + ("product_tmpl_id", '=', res.product_id.product_tmpl_id.id)], + limit=1) + + nomenclature = self.env['barcode.nomenclature'].browse(1) + ean13_digit = nomenclature.sanitize_ean(ean13) + ean13_verif_digit = nomenclature.sanitize_ean(ean13_verif) + + vals = { + "date_iso": today, + 'qrcode': 'https://qr.mayam.fr/' + str(res.container_id.barcode), + "container_ean13": res.container_id.barcode, + "product_id": res.product_id.id, + "name": res.product_id.name, + "price_net": res.price_subtotal, + "price_product": res.price_unit, + "weight_net": res.qty, + "weight_tare": res.container_weight, + "seller_name": seller_id.name.name, + "seller_code": seller_id.product_code, + "ean13": ean13_digit, + "ean13_verif": ean13_verif_digit, + "is_pos": True, + "balance_id": res.caisse_id + } + self.env['pos.transaction'].create(vals) return res # ------------------------------------------------------ # Actions