Add method to format warning name with records

issue10507
review346471002
This commit is contained in:
Cédric Krier committed 2021-06-17 09:25:40 +02:00
1 parent fe763b56ee
commit 916c0d0eca
2 files changed
+4 -11

No files matched your search

+1 -5
View File
@@ -1,7 +1,5 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import hashlib
from sql import Null
from trytond.i18n import gettext
@@ -166,9 +164,7 @@ class Inventory(Workflow, ModelSQL, ModelView):
names = ', '.join(i.rec_name for i in future_inventories[:5])
if len(future_inventories) > 5:
names + '...'
warning_name = (
'%s.date_future' % hashlib.md5(
str(future_inventories).encode('utf-8')).hexdigest())
warning_name = Warning.format('date_future', future_inventories)
if Warning.check(warning_name):
raise InventoryFutureWarning(warning_name,
gettext('stock.msg_inventory_date_in_the_future',
+3 -6
View File
@@ -1,7 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import datetime
import hashlib
import operator
from decimal import Decimal
from collections import OrderedDict, defaultdict
@@ -710,9 +709,8 @@ class Move(Workflow, ModelSQL, ModelView):
names = ', '.join(m.rec_name for m in future_moves[:5])
if len(future_moves) > 5:
names += '...'
warning_name = (
'%s.effective_date_future' % hashlib.md5(
str(future_moves).encode('utf-8')).hexdigest())
warning_name = Warning.format(
'effective_date_future', future_moves)
if Warning.check(warning_name):
raise MoveFutureWarning(warning_name,
gettext('stock.msg_move_effective_date_in_the_future',
@@ -875,8 +873,7 @@ class Move(Workflow, ModelSQL, ModelView):
names = ', '.join(m.rec_name for m in moves[:5])
if len(moves) > 5:
names += '...'
warning_name = '%s.done' % hashlib.md5(
str(moves).encode('utf-8')).hexdigest()
warning_name = Warning.format('done', moves)
if Warning.check(warning_name):
raise MoveOriginWarning(warning_name,
gettext('stock.msg_move_no_origin',