Reschedule planned date for late productions

Closes #11494
This commit is contained in:
Adrià Tarroja Caubet
2023-01-18 17:34:20 +01:00
parent cd81e8e793
commit cb7970a350
2 changed files with 24 additions and 5 deletions
+1
View File
@@ -1,3 +1,4 @@
* Reschedule planned date for late productions
Version 6.8.0 - 2023-05-01
--------------------------
+23 -5
View File
@@ -35,7 +35,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
})
planned_date = fields.Date('Planned Date',
states={
'readonly': ~Eval('state').in_(['request', 'draft']),
'readonly': Eval('state').in_(['cancelled', 'done']),
})
effective_date = fields.Date('Effective Date',
states={
@@ -795,7 +795,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
cls.assign(to_assign)
@classmethod
def _get_reschedule_domain(cls, date):
def _get_reschedule_planned_start_dates_domain(cls, date):
context = Transaction().context
return [
('company', '=', context.get('company')),
@@ -803,17 +803,35 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
('planned_start_date', '<', date),
]
@classmethod
def _get_reschedule_planned_dates_domain(cls, date):
context = Transaction().context
return [
('company', '=', context.get('company')),
('state', '=', 'running'),
('planned_date', '<', date),
]
@classmethod
def reschedule(cls, date=None):
pool = Pool()
Date = pool.get('ir.date')
if date is None:
date = Date.today()
productions = cls.search(cls._get_reschedule_domain(date))
for production in productions:
to_reschedule_start_date = cls.search(
cls._get_reschedule_planned_start_dates_domain(date))
to_reschedule_planned_date = cls.search(
cls._get_reschedule_planned_dates_domain(date))
for production in to_reschedule_start_date:
production.planned_start_date = date
production.on_change_planned_start_date()
cls.save(productions)
for production in to_reschedule_planned_date:
production.planned_date = date
cls.save(to_reschedule_start_date + to_reschedule_planned_date)
@property
@fields.depends('warehouse')