Lock journal period when automatically creating one
This avoids uniqueness constraint error in case of concurrent creation. Closes #10747 (grafted from c4674b8f6fbda574212a4b1768afd86f4651f7c7) --HG-- branch : 6.0
This commit is contained in:
@@ -1131,6 +1131,10 @@ class Line(ModelSQL, ModelView):
|
||||
and if there is no journal - period, create it
|
||||
'''
|
||||
JournalPeriod = Pool().get('account.journal.period')
|
||||
transaction = Transaction()
|
||||
database = transaction.database
|
||||
connection = transaction.connection
|
||||
|
||||
journal_periods = JournalPeriod.search([
|
||||
('journal', '=', journal.id),
|
||||
('period', '=', period.id),
|
||||
@@ -1142,6 +1146,7 @@ class Line(ModelSQL, ModelView):
|
||||
gettext('account.msg_modify_line_closed_journal_period',
|
||||
journal_period=journal_period.rec_name))
|
||||
else:
|
||||
database.lock(connection, JournalPeriod._table)
|
||||
JournalPeriod.create([{
|
||||
'journal': journal.id,
|
||||
'period': period.id,
|
||||
|
||||
Reference in New Issue
Block a user