Facturation interne : problème lorsque l'on génère plusieurs devis de suite
lors de la validation d'un devis, on génère une commande fournisseur. À la validation du premier devis, cela fonctionne comme attendu. À la validation du deuxième devis, une erreur apparaît :
File "/home/gas/endi/endi/endi/models/services/naming.py", line 95, in get_label_for_context
business_type_id = context.business_type_id
File "/home/gas/.virtualenvs/endi/lib64/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 480, in __get__
return self.impl.get(state, dict_)
File "/home/gas/.virtualenvs/endi/lib64/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 922, in get
value = state._load_expired(state, passive)
File "/home/gas/.virtualenvs/endi/lib64/python3.7/site-packages/sqlalchemy/orm/state.py", line 675, in _load_expired
self.manager.expired_attribute_loader(self, toload, passive)
File "/home/gas/.virtualenvs/endi/lib64/python3.7/site-packages/sqlalchemy/orm/loading.py", line 1345, in load_scalar_attributes
"attribute refresh operation cannot proceed" % (state_str(state))
DetachedInstanceError: Instance <InternalEstimation at 0x7fb65539a190> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/14/bhk3)
Le problème semble provenir du fait que la clotûre de la transaction par transaction.commit() n'affecte pas la session comme elle devrait.
Les logs sqlalchemy indiquent qu'il y a un cache en jeu qui serait en cause
SELECT task.id AS task_id, node.id AS node_id, node.name AS node_name, node.parent_id AS node_parent_id, node.type_ AS node_type_, node._acl AS node__acl, node.created_at AS node_created_at, node.updated_at AS node_updated_at, task.frozen_settings AS task_frozen_settings, task.phase_id AS task_phase_id, task.`status` AS task_status, task.status_comment AS task_status_comment, task.status_person_id AS task_status_person_id, task.status_date AS task_status_date, task.date AS task_date, task.owner_id AS task_owner_id, task.description AS task_description, task.`mode` AS task_mode, task.ht AS task_ht, task.tva AS task_tva, task.ttc AS task_ttc, task.company_id AS task_company_id, task.project_id AS task_project_id, task.customer_id AS task_customer_id, task.official_number AS task_official_number, task.legacy_number AS task_legacy_number, task.business_type_id AS task_business_type_id, task.business_id AS task_business_id, task.price_study_id AS task_price_study_id, task.start_date AS task_start_date, task.auto_validated AS task_auto_validated FROM node INNER JOIN task ON node.id = task.id WHERE node.id = %s [cached since 14.33s ago] (162993,)
À investiguer : comment le cache sqlalchemy est-il géré ?