How to handle this lock

Hi, I handle this message when posting an invoice?

   Invoice.post([invoice])
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelview.py", line 720, in wrapper
     return func(cls, records, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelview.py", line 734, in wrapper
     value = func(*args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelview.py", line 720, in wrapper
     return func(cls, records, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/workflow.py", line 37, in wrapper
     result = func(cls, filtered, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelview.py", line 720, in wrapper
     return func(cls, records, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/workflow.py", line 37, in wrapper
     result = func(cls, filtered, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/account_invoice/invoice.py", line 1698, in post
     cls._post(invoices)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/sale/invoice.py", line 22, in wrapper
     func(cls, invoices)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/sale/invoice.py", line 75, in _post
     super()._post(invoices)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/account_invoice_stock/account.py", line 26, in _post
     super()._post(invoices)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/account_invoice/invoice.py", line 1717, in _post
     Move.save(moves)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/descriptors.py", line 33, in newfunc
     return self.func(owner, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelstorage.py", line 1965, in save
     news = cls.create([save_values[r] for r in to_create])
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/account/move.py", line 309, in create
     return super().create(vlist)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelsql.py", line 234, in wrapper
     return func(cls, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelsql.py", line 922, in create
     field.set(cls, fname, *fargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/fields/one2many.py", line 290, in set
     Target.create(to_create)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/account/move.py", line 1466, in create
     cls.check_journal_period_modify(period, journal)
   File "/opt/terra/lib/python3.9/site-packages/trytond/modules/account/move.py", line 1346, in check_journal_period_modify
     JournalPeriod.lock()
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/descriptors.py", line 33, in newfunc
     return self.func(owner, *args, **kwargs)
   File "/opt/terra/lib/python3.9/site-packages/trytond/model/modelsql.py", line 2114, in lock
     transaction.lock_table(cls._table)
   File "/opt/terra/lib/python3.9/site-packages/trytond/transaction.py", line 299, in lock_table

Thanks.

This messages comes from this line.

Since Lock table is not enough to ensure to read last committed values (#10870) · Issues · Tryton / Tryton · GitLab, the lock of tables must be done at the transaction start.

PS: it will be better to have the full raw traceback

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.