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.
This commit is contained in:
Cédric Krier
2025-08-23 21:18:43 +02:00
parent c169d22f96
commit 7f0cb85631
+11 -11
View File
@@ -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)