Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

[V8]Use on_change to calculate a timedate field?

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
v8pythonpostimestampdefinition
5907 Vistas
Avatar
FEDERICO LEONI

I'm trying to calculate how much time expressed in minutes passed from the creation of a pos.order till the end on a  work center. I'm inherit the point_of_sale with a custom module:

class pos_order(osv.Model):
    _inherit = 'pos.order'

def on_change_kot_time(self,cr,user,ids,date_order,x_kot_time,context=None):
fmt = '%m/%d/%Y %H:%M:%S'
d1 = datetime.strptime(date_order, fmt)
d2 = datetime.strptime(x_kot_time, fmt)
d1_ts = time.mktime(d1.timetuple())
d2_ts = time.mktime(d2.timetuple())
timekot = int(d2_ts-d1_ts) / 60
res = {
'value': {
'x_minutes': timekot,
}
}
return res

but calling the definition with

<field name="field" on_change="on_change_kot_time(date_order,x_kot_time)/> 

on pos.order for the field date_order and my two custom fields (x_kot_time and x_minutes) didn't out the result and rise no errors. Just a side note: the x_kot_time is a timedate populated by a (working) server action with the python expression

datetime.datetime.now()

What I'm missing?

0
Avatar
Descartar
Yenthe Van Ginneken (Mainframe Monkey)

Have you tried adding alerts in your JS to see what is inside your variables and if it even goes off? I can't see any explicit problem at the moment. Try to debug your values to see if those methods are actually triggered and see what is in the variables.

FEDERICO LEONI
Autor

Yenthe, I have no idea on how to do that.

FEDERICO LEONI
Autor

Still stuck. I played around with the Chrome console but I can't see any error. Any idea?

Yenthe Van Ginneken (Mainframe Monkey)

You could try with a simple window.alert? And if you want to do debugging/logging in Python, this tutorial works great: http://www.mindissoftware.com/2014/09/07/Odoo-logging-configuration-usage-implementation/

FEDERICO LEONI
Autor

Tried with:

import logging

_logger = logging.getLogger(__name__)
LOG_FILENAME = '/home/effe/divina_log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
And at the end of the function:
	_logger.debug("date_order value : %r", d1)
	_logger.debug("end_date value : %r", d2)
	_logger.debug("date_order_timestamp value : %r", d1_ts)
	_logger.debug("end_date_timestamp value : %r", d2_ts)
	_logger.debug("timekot value : %r", timekot)
	_logger.debug("minutes value : %r", minutes)
    
But the log file remains blank.
FEDERICO LEONI
Autor

Please note I've changed the name of the variables. Again it works fine directly on pycharm with psycopg2.

FEDERICO LEONI
Autor

I give up. In less than an hour I create a new .py that is listening to the db and update it out from Odoo. No issues so far after processing more than 500 orders (+/- 900 rows) while using Odoo at the same time. I'm sorry to say that even with the new "skin" Odoo documentation is really inadequate.

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
[SOLVED] [V8] Is it possible to concatenate fields after filter them? Resuelto
v8 python pos personalization concatenate
Avatar
1
jun 15
5516
[V8] How to add timestamp to a processed order and calculate the time?
v8 fields pos custom timestamp
Avatar
1
jun 15
6557
Any method to group products in POS terminal?
v8 pos
Avatar
Avatar
1
jul 19
5000
POS and payment method
v8 pos
Avatar
Avatar
1
jun 16
5256
POS and product description
v8 pos
Avatar
0
jun 16
4401
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now