Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
pythontransaction6.17.08.0cr.commitrisk
1 Beantwoorden
35880 Weergaven
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
Annuleer
IBS Group

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

klacus
Auteur

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
Beste antwoord

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
Annuleer
klacus
Auteur

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

Med Said BARA

can you be more explicit?

klacus
Auteur

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
Auteur

Thx Med. i will try it soon as possible.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Function field result error record[f] = res2[record['id']] KeyError: 9
python 6.1
Avatar
0
mrt. 15
5496
Will it be difficult task to switch from 7.0 to 8.0 ?
upgrade 7.0 8.0
Avatar
Avatar
Avatar
2
mrt. 15
8245
Assign user to the Multi Companies group using the API?
python api 7.0
Avatar
0
mrt. 15
5104
How does the resolve_2many_commands method work?
python osv 7.0
Avatar
Avatar
1
mrt. 15
9822
How can i merge couple of fields into one (py)? Opgelost
python fields merge 8.0
Avatar
Avatar
1
apr. 15
5910
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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