Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

Confirm multiple sales

Suscribirse

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

Se marcó esta pregunta
3 Respuestas
4351 Vistas
Avatar
arthur

Hello, I am migrating from an Old ERP to Odoo and just imported the previous sales we, in order to keep it all on Odoo. The thing is that all sales are Quotations and now I have to Confirm them all and generate invoices from them in order to keep the data. I made a script that allows me to select the sales I want to to confirm and them loop through them. The code I have is the following:

@api.multi
def confirm_sales(self):
sale_orders = self.env['sale.order'].browse(self._context.get('active_ids', []))
count = 0
for sale_order in sale_orders:
count = count + 1
_logger.info("Sale: %s/%s", count, len(sale_orders))
if sale_order.state == 'sale':
_logger.info("It's sales order already")
continue
sale_order.action_confirm()
self.env.cr.commit()

  The problem is that there over 13K sales to be confirmed and when I try to run it on odoo.sh, each iteration takes a lot time and the script simply stops and no errors are thrown. I suspect this occurs due the number of sales being confirmed, but I am not sure that is it.

Does anyone know a way I can run I can successfully run this script? A fast way would be great =P

Thanks!

Arthur

0
Avatar
Descartar
Avatar
Ibrahim Boudmir
Mejor respuesta

Hi arthur,

First of all, 13K records will definitely take time. Be patient. 

Secondly,  if you run your script via XMLRPC, cron.. self._context.get('active_ids', []) will be empty as you have no active ids.. You need to call search function to search for records with state = 'draft' or state='sent'. 
These are the records you want to confirm. 

this would be : 

@api.multi
def confirm_sales(self):
    sale_orders = self.env['sale.order'].search([('state','in', ('draft', 'sent'))])
    count = 0
    for sale_order in sale_orders:
        count += 1
        _logger.info("Sale: %s/%s", count, len(sale_orders))
        sale_order.action_confirm()

Applying these changes would decrease probably the number of records that should be updated. 
0
Avatar
Descartar
Avatar
La Jayuhni Yarsyah
Mejor respuesta

I had faced a similar problem like yours

Odoo ORM need huge resource,  for example, only for just 1 sale record to execute confirm action, it require dozens of transaction depends on how much order item (sale order line),, even hundreds

if i confirm more than 2000 records the process will be stopped with no errors,, (simmiliar with your problem)

In my case, It stopped caused by the webserver (nginx) has limit for request and waiting response from the server and few more things like buffer size and else that i need to configure up,,
 
So beacause i run out of time,, i decide to make automated action (ir.cron) to execute python code,, and set interval for 10 or 15 minute,

And on python code i set then command to find the outstanding  records (find records wich not executed before) and limited to hundreds (in my case, i set limit 1000 records / cron action to execute)


And 1 more,, you must optimize your code,, for saving times to execute your code,,

For example,  in my opinion why don't you filter the record first,, so no loops on records that no need to be executed...
Example:

sale_orders = self.env['sale.order'].search([('state','!=','sale')], (**another domain))
# then loops after filtering data
for sale_order in sale_orders:
    # Executed here


Hope Helping you, Just share my experience
Regards

0
Avatar
Descartar
Avatar
Haresh Kansara
Mejor respuesta

Hi arthur,

i think it's happen due to large number of records,

i can give you one hint from that you can do it.

You can add one flag field (Boolean) in sale.order using inheritance, that just confirm that this order confirmed.

in your script you have to update that flag field when your order confirm,

so when you browse all sale order then set domain that only flag=False records are capture.

don't forget to accept answer if it's helpful for you.


Thank you.

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

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

Registrarse
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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