From bd8250a3cb616bba8b709ec0bd3f0f94fe483f66 Mon Sep 17 00:00:00 2001 From: Paramjit Singh Sahota Date: Thu, 6 Dec 2012 14:30:38 +0530 Subject: [PATCH] [IMP] Improved onchange. bzr revid: psa@tinyerp.com-20121206090038-umqu0sce210mtmpp --- addons/mrp_operations/mrp_operations.py | 12 +++++------- addons/mrp_operations/mrp_operations_view.xml | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 890827c0e07..fe8456ddaa2 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -26,7 +26,6 @@ import time from datetime import datetime from tools.translate import _ from datetime import timedelta -from dateutil.relativedelta import relativedelta #---------------------------------------------------------- # Work Centers @@ -72,14 +71,13 @@ class mrp_production_workcenter_line(osv.osv): res[op.id] = op.date_planned return res - # def onchange_get_date_end(self, cr, uid, ids, workcenter_id, date_planned, cycle, hour, context=None): - def onchange_get_date_end(self, cr, uid, ids, workcenter_id, date_planned, cycle, hour, context=None): + def onchange_get_date_end(self, cr, uid, ids, date_planned, cycle, hour): res = {'value':{}} - yo = cycle * hour - if date_planned and isinstance(date_planned, str): + cycle_per_hour = timedelta(hours=(cycle * hour)) + if date_planned : date_planned = datetime.strptime(date_planned, "%Y-%m-%d %H:%M:%S") - date_planned_end = date_planned + timedelta(hours=yo) - res['value'] = {'date_planned_end': date_planned_end.strftime("%Y-%m-%d %H:%M:%S")} + date_planned_end = date_planned + cycle_per_hour + res['value'] = {'date_planned_end': date_planned_end.strftime("%Y-%m-%d %H:%M:%S")} return res # def onchange_get_date_end(self, cr, uid, ids, date_planned, cycle, hour, context=None): diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 32615bf5742..1da32d2e90d 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -75,7 +75,7 @@ - + @@ -84,13 +84,13 @@ - + - - + +