Search code examples
pythonpostgresqlormodooodoo-13

Odoo ORM vs SQL


We're having problems accessing records created by the ORM, via direct SQL queries as it seems to be not finding these created records in the DB.

my question is how often does the Odoo ORM commit changes to the Postgres DB?


Solution

  • I searched and found an anwser on the Odoo forums:

    Odoo auto commits the changes you make at the end of the transaction, by calling cr.commit().

    Although you can call: cr.commit() it is not recommended to do so unless you have created your own database cursor explicitly! And the situations where you need to do that are exceptional! and you need to handle error cases and proper rollback, as well as properly close the cursor when you're done with it.

    Never commit the transaction