Commit Graph
6 Commits
Author SHA1 Message Date
william-andre c45998c836 [FIX] account: unique constraint in sequence mixin
Change the way the uniqueness of the sequence numbers is ensured.
Instead of using a `SELECT FOR UPDATE` approach inspired from the
`ir.sequence`, or even a true UPDATE, we can use a constraint approach.

SELECT FOR UPDATE
=================

By doing a FOR UPDATE NO WAIT, we are throwing an exception when another
transaction is creating a move using the same sequence as this one, by
locking the row that holds the current greatest sequence.
Since the row doesn't change, the lock is released and the following
UPDATE is allowed. Because of this, a "useless" UPDATE was always done
on the previous row to ensure a SerializationFailureError if two
concurrent transactions were trying to assign the same number.
This means that in a database with a lot of concurrent transactions
(typically with an online shop), many transactions were
aborted/rollbacked.
This approach also has the drawback of having the constraint implemented
python side, which is less robust.

UNIQUE CONSTRAINT
=================

Using a constraint on the database level means that the database knows
when some transactions will try to do something similar. It will
therefore make the concurrent transactions wait instead of aborting the
transaction.
It is however harder to have the constraint customized by different
modules/localization because it is now done directly in the database and
not in python. Changing the constraint means deleting/recreating the
index. For now, this only happens for Latin America l10n, so a simple
hardcoded approach is implemented.
In order to achieve this, the business code is trying to use the
sequence incrementally until it gets a number it can use for when
multiple transactions are concurrent.

closes odoo/odoo#106325

X-original-commit: 4b430f8e30efb15f06982e4673cd73531a2119b3
Related: odoo/enterprise#34297
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2022-11-23 16:14:45 +01:00
qdp-odoo c04065abd8 [IMP] accounting v9. Yeeeeaah 2015-05-05 17:28:04 +02:00
Leonardo Donelli 4a0b13ed92 [REF] remove vim modelines and resulting trailing blank lines
Let 2015 be a year without modelines!
cf #4174
2014-12-31 15:52:13 +01:00
Numerigraphe - Lionel Sausin 2d2a44dcf2 [FIX] unmutable default in the remaining modules
[REF] coding style consistency

lp bug: https://launchpad.net/bugs/525808 fixed

bzr revid: ls@numerigraphe.fr-20120305184003-er00xtj9vtcw7gna
2012-03-05 19:40:03 +01:00
mtr 396bbe73e1 [ADD] Account_sequence: added installer files
bzr revid: mtr@mtr-20101123104633-cnvoe6f8rm7ufq9c
2010-11-23 16:16:33 +05:30
mtr f0c123111c [ADD]:-added 'account_sequence' module to maintain internal sequence number on the accounting entries
bzr revid: mtr@mtr-20101103082639-xd4a0pwkabqit2t7
2010-11-03 13:56:39 +05:30