Use decorator before ModelView.button to set default records for cron task

Closes #15076
This commit is contained in:
Cédric Krier committed 2026-09-09 12:22:52 +02:00
1 parent 1bc165be5e
commit bdefd24bbc
2 files changed
+36 -35

No files matched your search

+15 -10
View File
@@ -1,6 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from functools import wraps
from itertools import groupby
from sql.conditionals import NullIf
@@ -24,6 +25,18 @@ else:
file_id = store_prefix = None
def default_records(func):
@wraps(func)
def wrapper(cls, documents=None):
if documents is None:
documents = cls.search([
('direction', '=', 'out'),
('state', '=', 'processing'),
])
return func(cls, documents)
return wrapper
class Peppol(Workflow, ModelSQL, ModelView):
__name__ = 'edocument.peppol'
@@ -246,17 +259,9 @@ class Peppol(Workflow, ModelSQL, ModelView):
self.succeed()
@classmethod
def update_status(cls, documents=None):
if documents is None:
documents = cls.search([
('direction', '=', 'out'),
('state', '=', 'processing'),
])
cls.update_status_button(documents)
@classmethod
@default_records
@ModelView.button
def update_status_button(cls, documents):
def update_status(cls, documents):
for document in documents:
document._update_status()
cls.save(documents)