Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

What is the cr.commit() risk, how to safe db write

Odebírat

Get notified when there's activity on this post

This question has been flagged
pythontransaction6.17.08.0cr.commitrisk
1 Odpovědět
35899 Zobrazení
Avatar
klacus

Hi.

I have a cycle like this.

for i in ids:

 self.pool.get('product.product').create(cr, uid, vals, context = context)

 cr.commit()

Now in empty system this is not cause any matter, but what is a risk, for this kind of execution? Think of live system with user activites, and so on.

If has what is a different's between 6.1, 7.0, 8.0 versions?

Regards.

Laci.

 

 

1
Avatar
Zrušit
IBS Group

Odoo auto commits the changes you make at the end of the transaction, why are you explicitly calling cr.commit() yourself?

klacus
Autor

Hi. Thanks for the reply. So I need the data sometimes as well, because I make a large calculation what is take's a lot of time. Sometimes this calculation cannot reach the end of transaction, because some exception raised, but some semi finish data is important for me, and this case I lost all of the calculated data. (I working on some diff. resource planner, what is need to recalculate the production, according the daily capacity and shift happening. ) Now I working on an automatic factory builder, what is create all of the things according few input data. (repacking routings, bill of material, create the sem finish parts, work instruction, according few templates) So in this case sometimes I create 200.000 lines In mrp.routing and I lost all, if some raw data is wrong. (template not exist, wrong mrp code and so on ) That's why I need to write manually the results what is ok.

IBS Group

I understand, in that case I don't think there is a risk associated with this, you are simply committing your changes immediately and it's just one line of code, so it shouldn't be a problem.

IBS Group

As long as you're sure that the batches of code you're committing wont cause a problem in case there is a failure, then it shouldn't be a problem. Just make sure to manage your transactions as the other member suggested in the answer to your question.

Avatar
Med Said BARA
Nejlepší odpověď

You should NEVER call cr.commit() yourself, UNLESS you have created your own database cursor explicitly! And the situations where you need to do that are exceptional!

And by the way if you did create your own cursor, then you need to handle error cases and proper rollback, as well as properly close the cursor when you're done with it.

From: https://doc.odoo.com/contribute/15_guidelines/coding_guidelines_framework/#never-commit-the-transaction

3
Avatar
Zrušit
klacus
Autor

Ok. What is the situation whit wizards? This can be commit own self?

Med Said BARA

can you be more explicit?

klacus
Autor

Hi Med. Can you explain me how to create an own database cursor, to take safe my activities?

Med Said BARA

It's in the above response;"And by the way if you did create your own cursor, then you need to handle error cases and proper rollback, as well as properly close the cursor when you're done with it." Keep in mind the "Transaction Isolation". To read: http://www.postgresql.org/docs/9.2/static/transaction-iso.html http://fossies.org/dox/odoo-7.saas-5/classopenerp_1_1sql__db_1_1Cursor.html

Med Said BARA

A good example: https://github.com/yeahliu/workflow_info/blob/master/controller.py

klacus
Autor

Thx Med. i will try it soon as possible.

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Function field result error record[f] = res2[record['id']] KeyError: 9
python 6.1
Avatar
0
bře 15
5497
Will it be difficult task to switch from 7.0 to 8.0 ?
upgrade 7.0 8.0
Avatar
Avatar
Avatar
2
bře 15
8251
Assign user to the Multi Companies group using the API?
python api 7.0
Avatar
0
bře 15
5105
How does the resolve_2many_commands method work?
python osv 7.0
Avatar
Avatar
1
bře 15
9827
How can i merge couple of fields into one (py)? Vyřešeno
python fields merge 8.0
Avatar
Avatar
1
dub 15
5926
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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