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

« back to all changes in this revision

Viewing changes to res_currency_tables/res_currency_table.py

  • Committer: Matthieu Dietrich
  • Date: 2012-02-21 10:47:32 UTC
  • mto: This revision was merged to the branch mainline in revision 682.
  • Revision ID: matthieu.dietrich@geneva.msf.org-20120221104732-k8cxphmeauu4n6z4
UF-755: [IMP] few things missing from currency tables

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import datetime
23
23
from osv import fields, osv
 
24
from tools.translate import _
24
25
 
25
26
class res_currency_table(osv.osv):
26
27
    _name = 'res.currency.table'
37
38
    _defaults = {
38
39
        'state': 'draft',
39
40
    }
 
41
    
 
42
    def validate(self, cr, uid, ids, context={}):
 
43
        if not context:
 
44
            context = {}
 
45
        # just get one table
 
46
        if not isinstance(ids, (int, long)):
 
47
            ids = ids[0]
 
48
        table = self.browse(cr, uid, ids, context=context)
 
49
        for currency in table.currency_ids:
 
50
            if currency.rate == 0.0:
 
51
                raise osv.except_osv(_('Error'), _('A currency has an invalid rate! Please set a rate before validation.'))
 
52
        
 
53
        return self.write(cr, uid, ids, {'state': 'valid'}, context=context)
40
54
 
41
55
    def _check_unicity(self, cr, uid, ids, context={}):
42
56
        if not context: