diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index a48b8d23a12..bdfcc9991a2 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -21,16 +21,12 @@ ############################################################################## import time -import math import mx.DateTime from mx.DateTime import RelativeDateTime, now, DateTime, localtime -from osv import fields -from osv import osv +from osv import osv, fields import netsvc - from tools.translate import _ -import tools from tools import config @@ -39,15 +35,14 @@ def rounding(fl, round_value): return fl return round(fl / round_value) * round_value - # Object creating periods quickly # changed that stop_date is created with hour 23:59:00 when it was 00:00:00 stop date was excluded from period class stock_period_createlines(osv.osv_memory): _name = "stock.period.createlines" - def _get_new_period_start(self,cr,uid,context={}): + def _get_new_period_start(self, cr, uid, context=None): cr.execute("select max(date_stop) from stock_period") - result=cr.fetchone() + result = cr.fetchone() last_date = result and result[0] or False if last_date: period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1) @@ -55,7 +50,7 @@ class stock_period_createlines(osv.osv_memory): else: period_start = mx.DateTime.today() return period_start.strftime('%Y-%m-%d') - + _columns = { 'name': fields.char('Period Name', size=64), @@ -64,47 +59,47 @@ class stock_period_createlines(osv.osv_memory): 'period_ids': fields.one2many('stock.period', 'planning_id', 'Periods'), } _defaults={ - 'date_start':_get_new_period_start, + 'date_start': _get_new_period_start, } - - def create_period_weekly(self,cr, uid, ids, context={}): - res=self.create_period(cr, uid, ids, context, 6, 'Weekly') + + def create_period_weekly(self, cr, uid, ids, context=None): + res = self.create_period(cr, uid, ids, context, 6, 'Weekly') return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', - 'type': 'ir.actions.act_window', + 'type': 'ir.actions.act_window', } - - def create_period_monthly(self,cr, uid, ids, context={},interval=1): - for p in self.browse(cr, uid, ids, context): + + def create_period_monthly(self,cr, uid, ids, interval=1, context=None): + for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') - while ds.strftime('%Y-%m-%d')