[FIX, IMP] stock_planning: Create Periods wizard error. Improved methods.

bzr revid: uco@tinyerp.com-20100715120943-tfiymtgi7poe2do3
This commit is contained in:
uco 2010-07-15 17:39:43 +05:30
parent 5249b531cd
commit 0f352e33e9
2 changed files with 9 additions and 6 deletions

View File

@ -27,7 +27,7 @@ from mx.DateTime import RelativeDateTime, now, DateTime, localtime
from osv import osv, fields
import netsvc
from tools.translate import _
from tools import config
#from tools import config
def rounding(fl, round_value):
@ -63,7 +63,7 @@ class stock_period_createlines(osv.osv_memory):
}
def create_period_weekly(self, cr, uid, ids, context=None):
res = self.create_period(cr, uid, ids, context, 6, 'Weekly')
res = self.create_period(cr, uid, ids, context=context)
return {
'view_type': 'form',
"view_mode": 'tree',
@ -71,7 +71,8 @@ class stock_period_createlines(osv.osv_memory):
'type': 'ir.actions.act_window',
}
def create_period_monthly(self,cr, uid, ids, interval=1, context=None):
def create_period_monthly(self, cr, uid, ids, context=None):
interval = context.get('interval',1)
for p in self.browse(cr, uid, ids, context=context):
dt = p.date_start
ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d')
@ -90,7 +91,9 @@ class stock_period_createlines(osv.osv_memory):
'type': 'ir.actions.act_window',
}
def create_period(self, cr, uid, ids, interval=0, name='Daily', context=None):
def create_period(self, cr, uid, ids, context=None):
interval = context.get('interval',0)
name = context.get('name','Daily')
for p in self.browse(cr, uid, ids, context=context):
dt = p.date_start
ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d')

View File

@ -19,8 +19,8 @@
<separator colspan="4" string=""/>
<group col="3" colspan="4">
<button name="create_period" icon="gtk-execute" string="Create Daily Periods" type="object"/>
<button name="create_period_weekly" icon="gtk-execute" string="Create Weekly Periods" type="object"/>
<button name="create_period_monthly" icon="gtk-execute" string="Create Monthly Periods" type="object"/>
<button name="create_period_weekly" icon="gtk-execute" string="Create Weekly Periods" type="object" context="{'interval': 6, 'name': 'Weekly'}"/>
<button name="create_period_monthly" icon="gtk-execute" string="Create Monthly Periods" type="object" context="{'interval': 1}"/>
</group>
</form>
</field>