51
51
_name = 'stock.frequence'
52
52
_description = 'Stock scheduler'
54
def get_selection(self, cr, uid, o, field, context=None):
54
def get_selection(self, cr, uid, o, field):
56
56
Returns the field.selection label
61
58
sel = self.pool.get(o._name).fields_get(cr, uid, [field])
62
59
res = dict(sel[field]['selection']).get(getattr(o,field),getattr(o,field))
63
60
name = '%s,%s' % (o._name, field)
64
tr_ids = self.pool.get('ir.translation').search(cr, uid, [('type', '=', 'selection'), ('name', '=', name),('src', '=', res), ('lang', '=', context.get('lang'))])
61
tr_ids = self.pool.get('ir.translation').search(cr, uid, [('type', '=', 'selection'), ('name', '=', name),('src', '=', res)])
66
63
return self.pool.get('ir.translation').read(cr, uid, tr_ids, ['value'])[0]['value']
378
375
Returns a description of the frequence
383
377
res = super(stock_frequence, self).name_get(cr, uid, ids, context=context)
385
379
# TODO: Modif of name_get method to return a comprehensive name for frequence
410
404
friday, saturday)
411
405
if freq.name == 'monthly':
412
406
if freq.monthly_one_day:
413
choose_freq = self.get_selection(cr, uid, freq, 'monthly_choose_freq', context=context)
414
choose_day = self.get_selection(cr, uid, freq, 'monthly_choose_day', context=context)
407
choose_freq = self.get_selection(cr, uid, freq, 'monthly_choose_freq')
408
choose_day = self.get_selection(cr, uid, freq, 'monthly_choose_day')
415
409
title = _('%s %s - Every %s month(s)') % (choose_freq, choose_day, freq.monthly_frequency)
416
410
elif freq.monthly_repeating_ok:
434
428
title += _(' - Every %s month(s)') % (freq.monthly_frequency,)
435
429
if freq.name == 'yearly':
436
430
if freq.yearly_day_ok:
437
month = self.get_selection(cr, uid, freq, 'yearly_choose_month', context=context)
431
month = self.get_selection(cr, uid, freq, 'yearly_choose_month')
439
433
if freq.yearly_day in (1, 21, 31):
445
439
title = _('All %s, the %s%s') %(month, freq.yearly_day, day_f)
446
440
elif freq.yearly_date_ok:
447
frequence = self.get_selection(cr, uid, freq, 'yearly_choose_freq', context=context)
448
day = self.get_selection(cr, uid, freq, 'yearly_choose_day', context=context)
449
month = self.get_selection(cr, uid, freq, 'yearly_choose_month_freq', context=context)
441
frequence = self.get_selection(cr, uid, freq, 'yearly_choose_freq')
442
day = self.get_selection(cr, uid, freq, 'yearly_choose_day')
443
month = self.get_selection(cr, uid, freq, 'yearly_choose_month_freq')
450
444
title = _('All %s %s in %s') % (frequence, day, month)
451
445
title += _(' - Every %s year(s)') %(freq.yearly_frequency)