From 94a476c090b13791c46bc32a7471316f205afa47 Mon Sep 17 00:00:00 2001 From: agaldona Date: Mon, 21 Sep 2015 12:52:24 +0200 Subject: [PATCH] =?UTF-8?q?[IMP]=20mrp=5Foperations=5Fextension:=20nuevas?= =?UTF-8?q?=20funcionalidades=20en=20workorders.=20Closes=20#750=20#812=20?= =?UTF-8?q?-=20Se=20han=20realizado=20solo=20algunos=20puntos=20del=20issu?= =?UTF-8?q?e=20ya=20que=20algunos=20de=20ellos=20se=20han=20solucionado=20?= =?UTF-8?q?en=20las=20nuevas=20actualizaciones=20=09-=20nueva=20vista=20ca?= =?UTF-8?q?lendario,=20seg=C3=BAn=20fechas=20previstas=20=09-=20permitir?= =?UTF-8?q?=20modificar=20la=20fecha=20planificada=20de=20una=20OF=20si=20?= =?UTF-8?q?no=20est=C3=A1=20iniciada=20=09-=20cambiar=20la=20fecha=20previ?= =?UTF-8?q?sta=20de=20una=20OF=20cuando=20se=20cambia=20la=20fecha=20previ?= =?UTF-8?q?sta=20de=20una=20OT=20si=20esta=20es=20menor=20que=20la=20de=20?= =?UTF-8?q?su=20OF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/mrp_production.py | 28 +++++++++++++++++++ .../views/mrp_production_view.xml | 14 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/mrp_operations_extension/models/mrp_production.py b/mrp_operations_extension/models/mrp_production.py index 453274471..fd5f75b6f 100644 --- a/mrp_operations_extension/models/mrp_production.py +++ b/mrp_operations_extension/models/mrp_production.py @@ -10,6 +10,9 @@ class MrpProduction(models.Model): _inherit = 'mrp.production' workcenter_lines = fields.One2many(readonly=False) + date_planned = fields.Datetime(states={'draft': [('readonly', False)], + 'confirmed': [('readonly', False)], + 'ready': [('readonly', False)]}) def _get_minor_sequence_operation(self, operations): return min(operations, key=lambda x: x.sequence) @@ -119,6 +122,31 @@ class MrpProductionWorkcenterLine(models.Model): def force_assign(self): self.move_lines.force_assign() + @api.multi + def _load_mo_date_planned(self, production, date_planned): + if date_planned < production.date_planned: + production.write({'date_planned': date_planned}) + + @api.model + def create(self, vals): + production_obj = self.env['mrp.production'] + dp = vals.get('date_planned', False) + production_id = vals.get('production_id', False) + if dp and production_id: + production = production_obj.browse(production_id) + self._load_mo_date_planned(production, dp) + return super(MrpProductionWorkcenterLine, self).create(vals) + + @api.multi + def write(self, vals, update=False): + if vals.get('date_planned', False): + dp = vals.get('date_planned') + self._load_mo_date_planned(self.production_id, dp) + update = True + res = super(MrpProductionWorkcenterLine, self).write(vals, + update=update) + return res + def check_minor_sequence_operations(self): seq = self.sequence for operation in self.production_id.workcenter_lines: diff --git a/mrp_operations_extension/views/mrp_production_view.xml b/mrp_operations_extension/views/mrp_production_view.xml index a8d7a1b72..4650f8260 100644 --- a/mrp_operations_extension/views/mrp_production_view.xml +++ b/mrp_operations_extension/views/mrp_production_view.xml @@ -225,5 +225,19 @@ + + + mrp.production.workcenter.line.future.calendar + mrp.production.workcenter.line + + + + + + + + + +