Faircot process
This commit is contained in:
@@ -295,23 +295,60 @@ class Incoming(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
|||||||
@ModelView.button
|
@ModelView.button
|
||||||
@Workflow.transition('processing')
|
@Workflow.transition('processing')
|
||||||
def process(cls, documents, with_children=False):
|
def process(cls, documents, with_children=False):
|
||||||
|
logger.info(
|
||||||
|
"DOCUMENT_INCOMING_PROCESS_CLICK documents=%s with_children=%s",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
'id': document.id,
|
||||||
|
'name': document.name,
|
||||||
|
'type': document.type,
|
||||||
|
'state': document.state,
|
||||||
|
}
|
||||||
|
for document in documents
|
||||||
|
],
|
||||||
|
with_children)
|
||||||
transaction = Transaction()
|
transaction = Transaction()
|
||||||
context = transaction.context
|
context = transaction.context
|
||||||
with transaction.set_context(
|
with transaction.set_context(
|
||||||
queue_batch=context.get('queue_batch', True)):
|
queue_batch=context.get('queue_batch', True)):
|
||||||
|
logger.info(
|
||||||
|
"DOCUMENT_INCOMING_PROCESS_QUEUE documents=%s queue_batch=%s",
|
||||||
|
[document.id for document in documents],
|
||||||
|
transaction.context.get('queue_batch'))
|
||||||
cls.__queue__.proceed(documents, with_children=with_children)
|
cls.__queue__.proceed(documents, with_children=with_children)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
@Workflow.transition('done')
|
@Workflow.transition('done')
|
||||||
def proceed(cls, documents, with_children=False):
|
def proceed(cls, documents, with_children=False):
|
||||||
|
logger.info(
|
||||||
|
"DOCUMENT_INCOMING_PROCEED_START documents=%s with_children=%s",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
'id': document.id,
|
||||||
|
'name': document.name,
|
||||||
|
'type': document.type,
|
||||||
|
'state': document.state,
|
||||||
|
'active': document.active,
|
||||||
|
'result': str(document.result) if document.result else None,
|
||||||
|
}
|
||||||
|
for document in documents
|
||||||
|
],
|
||||||
|
with_children)
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Attachment = pool.get('ir.attachment')
|
Attachment = pool.get('ir.attachment')
|
||||||
results = defaultdict(list)
|
results = defaultdict(list)
|
||||||
attachments = []
|
attachments = []
|
||||||
for document in documents:
|
for document in documents:
|
||||||
if document.result or not document.active:
|
if document.result or not document.active:
|
||||||
|
logger.info(
|
||||||
|
"DOCUMENT_INCOMING_PROCEED_SKIP document=%s "
|
||||||
|
"result=%s active=%s",
|
||||||
|
document.id, document.result, document.active)
|
||||||
continue
|
continue
|
||||||
|
logger.info(
|
||||||
|
"DOCUMENT_INCOMING_PROCEED_DISPATCH document=%s method=%s",
|
||||||
|
document.id, f'_process_{document.type}')
|
||||||
document.result = getattr(document, f'_process_{document.type}')()
|
document.result = getattr(document, f'_process_{document.type}')()
|
||||||
results[document.result.__class__].append(document.result)
|
results[document.result.__class__].append(document.result)
|
||||||
attachment = Attachment(
|
attachment = Attachment(
|
||||||
|
|||||||
Reference in New Issue
Block a user