Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Confirm multiple sales

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
3 Odpowiedzi
4353 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Ibrahim Boudmir
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
La Jayuhni Yarsyah
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Haresh Kansara
Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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