From 7f0cb85631cbbeb04333d8440aefbf91d1e37c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 23 Aug 2025 21:18:43 +0200 Subject: [PATCH] Check for assigned move per company and recent date d84b63604b10 calculates the recent date per company so we must search for moves using this date for the same company. --- modules/stock/period.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/stock/period.py b/modules/stock/period.py index f565d4868b..f5940ec7ee 100644 --- a/modules/stock/period.py +++ b/modules/stock/period.py @@ -119,7 +119,6 @@ class Period(Workflow, ModelSQL, ModelView): ('type', 'not in', ['warehouse', 'view']), ], order=[]) - recent_date = None for company, c_periods in groupby(periods, key=lambda p: p.company): with Transaction().set_context(company=company.id): today = Date.today() @@ -127,16 +126,17 @@ class Period(Workflow, ModelSQL, ModelView): if recent_date >= today: raise PeriodCloseError( gettext('stock.msg_period_close_date')) - if Move.search([ - ('state', '=', 'assigned'), - ['OR', [ - ('effective_date', '=', None), - ('planned_date', '<=', recent_date), - ], - ('effective_date', '<=', recent_date), - ]]): - raise PeriodCloseError( - gettext('stock.msg_period_close_assigned_move')) + if Move.search([ + ('company', '=', company.id), + ('state', '=', 'assigned'), + ['OR', [ + ('effective_date', '=', None), + ('planned_date', '<=', recent_date), + ], + ('effective_date', '<=', recent_date), + ]]): + raise PeriodCloseError( + gettext('stock.msg_period_close_assigned_move')) for grouping in cls.groupings(): Cache = cls.get_cache(grouping)