Browse Source

[FIX] Bug on pos order line cretate to send mayam POS

12.0
Juliana 3 years ago
parent
commit
cd9d2f4662
  1. 2
      __manifest__.py
  2. 2
      models/__init__.py
  3. 84
      models/pos_order_line.py

2
__manifest__.py

@ -1,7 +1,7 @@
{ {
"name": "VRACOOP - POS API Mayam", "name": "VRACOOP - POS API Mayam",
"summary": "POS API Mayam", "summary": "POS API Mayam",
"version": "12.0.1.0.1",
"version": "12.0.1.1.1",
"development_status": "Beta", "development_status": "Beta",
"author": "Le Filament", "author": "Le Filament",
"maintainers": ["remi-filament"], "maintainers": ["remi-filament"],

2
models/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
# from . import pos_order_line
from . import pos_order_line
from . import pos_transaction from . import pos_transaction

84
models/pos_order_line.py

@ -11,7 +11,7 @@ class PosOrderLine(models.Model):
# ------------------------------------------------------ # ------------------------------------------------------
# Fields declaration # Fields declaration
# ------------------------------------------------------ # ------------------------------------------------------
caisse_id = fields.Char('Id de la caisse')
# ------------------------------------------------------ # ------------------------------------------------------
# SQL Constraints # SQL Constraints
# ------------------------------------------------------ # ------------------------------------------------------
@ -34,44 +34,50 @@ class PosOrderLine(models.Model):
@api.model @api.model
def create(self, values): def create(self, values):
res = super(PosOrderLine, self).create(values) res = super(PosOrderLine, self).create(values)
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)
prod = (res.product_id.default_code).zfill(5)
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,
}
self.env['pos.transaction'].create(vals)
if not res.order_id.config_id.is_balance_free:
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)
return res return res
# ------------------------------------------------------ # ------------------------------------------------------
# Actions # Actions

Loading…
Cancel
Save