~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to stock_schedule/schedule.py

  • Committer: jf
  • Date: 2012-08-03 14:15:44 UTC
  • mfrom: (1071.2.4 uf-1303)
  • Revision ID: jf@tempo4-20120803141544-xaplb4ot6do2b7iz
UF-1311 [FIX] Column of local expense should not be all in bold
UF-1310 [FIX] A menu is missing in supply configuration
lp:~unifield-team/unifield-wm/uf-1310

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    _name = 'stock.frequence'
52
52
    _description = 'Stock scheduler'
53
53
    
54
 
    def get_selection(self, cr, uid, o, field, context=None):
 
54
    def get_selection(self, cr, uid, o, field):
55
55
        """
56
56
        Returns the field.selection label
57
57
        """
58
 
        if not context:
59
 
            context = {}
60
 
 
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)])
65
62
        if tr_ids:
66
63
            return self.pool.get('ir.translation').read(cr, uid, tr_ids, ['value'])[0]['value']
67
64
        else:
377
374
        '''
378
375
        Returns a description of the frequence
379
376
        '''
380
 
        if not context:
381
 
            context = {}
382
 
 
383
377
        res = super(stock_frequence, self).name_get(cr, uid, ids, context=context)
384
378
        
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:
417
411
                    title = _('On ')
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')
438
432
                    day_f = 'th'
439
433
                    if freq.yearly_day in (1, 21, 31):
440
434
                        day_f = 'st'
444
438
                        day_f = 'rd'
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)
452
446