erp5_invoicing: make sure get correct SM
if user deliver invoice transaction just after journalise, some times, we can notice that accounting lines are added even invoice transaction is already in stopped state
here is an example: sale invoice transaction is delivered at 09:30:20.995795 UTC
stop_action superxiaowu accounting_workflow:started 2022/05/02 09:30:20.978878 UTC stop superxiaowu accounting_workflow:stopped 2022/05/02 09:30:20.995795 UTC
accounting line is added at 09:30:28.538010 UTC
/nexedi/accounting_module/20220502-3DD4B45/_localBuild /nexedi/acl_users System Processe ... 2022/05/02 09:30:28.538010 UTC
the reason is that InvoiceTransaction_selectInvoiceMovement get wrong state SM:
here is some trackback:
------ 2022-05-02 09:30:17,457 INFO InvoiceTransaction_selectInvoiceMovement, 37: get started sm ------ 2022-05-02 09:30:17,459 INFO InvoiceTransaction_selectInvoiceMovement, 37: get started sm ------ 2022-05-02 09:30:17,579 INFO InvoiceTransaction_selectDelivery, 27: {Sale Invoice Transaction at /nexedi/accounting_module/20220502-3DD4B45: 1} ==> slappart8/var/log/zope-0-event.log <== ***************************** deliver sale invoice transaction ------ 2022-05-02 09:30:21,512 INFO RuleTool Updating simulation for /nexedi/accounting_module/20220502-3DD4B45: {'create_root': 1, 'index_related': 1} ==> slappart5/var/log/zope-0-event.log <== ------ 2022-05-02 09:30:22,892 WARNING SQLDict Exception raised when invoking messages (uid, path, method_id) [(275788776658006010L, ('', 'nexedi', 'accounting_module', '20220502-3DD4B45'), '_localBuild')] Traceback (most recent call last): File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/parts/erp5/product/CMFActivity/Activity/SQLBase.py", line 868, in dequeueMessage transaction.commit() File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/transaction-1.7.0-py2.7.egg/transaction/_manager.py", line 123, in commit return self.get().commit() File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/transaction-1.7.0-py2.7.egg/transaction/_transaction.py", line 280, in commit reraise(t, v, tb) File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/transaction-1.7.0-py2.7.egg/transaction/_transaction.py", line 271, in commit self._commitResources() File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/Products.TIDStorage-5.5.0-py2.7.egg/Products/TIDStorage/transaction_transaction.py", line 25 1, in _commitResources result = original__commitResources(self, *args, **kw) File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/transaction-1.7.0-py2.7.egg/transaction/_transaction.py", line 416, in _commitResources reraise(t, v, tb) File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/transaction-1.7.0-py2.7.egg/transaction/_transaction.py", line 390, in _commitResources rm.commit(self) File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/ZODB-4.4.5-py2.7.egg/ZODB/Connection.py", line 582, in commit self._commit(transaction) File "/srv/slapgrid/slappart16/srv/runner/software/cc627918c55102e3f1a6c6a0077f41bb/eggs/ZODB-4.4.5-py2.7.egg/ZODB/Connection.py", line 630, in _commit raise ConflictError(object=obj) ConflictError: database conflict error (oid 0x0c78a313, class erp5.portal_type.Sale Invoice Transaction) ------ ******************* /nexedi/accounting_module/20220502-3DD4B45 localbuild restart because of ConflictError 2022-05-02 09:30:23,340 INFO InvoiceTransaction_selectInvoiceMovement, 37: get stopped sm ------ 2022-05-02 09:30:23,342 INFO InvoiceTransaction_selectInvoiceMovement, 37: get stopped sm ------ 2022-05-02 09:30:23,381 INFO InvoiceTransaction_selectDelivery, 27: {Sale Invoice Transaction at /nexedi/accounting_module/20220502-3DD4B45: 1}
InvoiceTransaction_selectInvoiceMovement is supposed to get started SM, but finally it get stopped SM, maybe because sql is not updated yet when do the query