[FIX]res_currency: change value from 0 to 1 when no rate is associated to a given period of time
in order to prevent division by zero error bzr revid: csn@openerp.com-20130313154342-g1d1jj3g061evf56
This commit is contained in:
parent
ab76b7a67f
commit
b5129816dc
|
@ -21,12 +21,15 @@
|
|||
|
||||
import re
|
||||
import time
|
||||
import logging
|
||||
|
||||
from openerp import tools
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools import float_round, float_is_zero, float_compare
|
||||
from openerp.tools.translate import _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
CURRENCY_DISPLAY_PATTERN = re.compile(r'(\w+)\s*(?:\((.*)\))?')
|
||||
|
||||
class res_currency(osv.osv):
|
||||
|
@ -49,7 +52,9 @@ class res_currency(osv.osv):
|
|||
id, rate = cr.fetchall()[0]
|
||||
res[id] = rate
|
||||
else:
|
||||
res[id] = 0
|
||||
#to prevent division by zero in case no rate exist for the defined period, we put the rate to one
|
||||
_logger.warning(("No currency rate associated for currency_id %d" % (id)))
|
||||
res[id] = 1
|
||||
return res
|
||||
_name = "res.currency"
|
||||
_description = "Currency"
|
||||
|
|
Loading…
Reference in New Issue