You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.9 KiB

# © 2020 Le Filament (<>)
# License AGPL-3.0 or later (
from odoo import api, fields, models
import pytz
from datetime import datetime
from pytz import timezone
class PosTransaction(models.Model):
_name = 'pos.transaction'
_description = 'Table des Transactions'
name = fields.Char('Ref Produit')
balance_id = fields.Char('Id de la balance')
qrcode = fields.Char("QRCode")
ean13 = fields.Char('EAN13 Poids Produits', size=13)
ean13_verif = fields.Char('EAN13 Vérification Poids', size=13)
date_iso = fields.Char('Date ISO', compute="_compute_date_iso")
container_ean13 = fields.Char('EAN13 Container', size=13)
weight_net = fields.Float('Poids Net (en kg)', digits=(12,3))
weight_tare = fields.Float('Poids Tare (en kg)', digits=(12,3))
price_net = fields.Float('Prix total')
price_product = fields.Float('Prix au kilo')
product_id = fields.Many2one('product.product', string='Produit ID')
def create_from_ui(self, transactions):
# retourne la liste des ids dans le même ordre que la liste fournie
transaction_ids = []
for transaction in transactions:
transaction_id = transaction.pop('id', False)
if transaction_id:
transaction_id = self.create(transaction).id
return transaction_ids
def _compute_date_iso(self):
for transaction in self:
# date_iso = pytz.utc.localize(transaction.write_date).astimezone(timezone('Europe/Berlin'))
# print("---date_iso ---", str(date_iso))
if hasattr(transaction.write_date, 'isoformat'):
transaction.date_iso = transaction.write_date.isoformat('T')[:19]