Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Confirm multiple sales

Subscriure's

Get notified when there's activity on this post

This question has been flagged
3 Respostes
4350 Vistes
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
Best Answer

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
Best Answer

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
Best Answer

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
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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