Arnaud Pineux (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-1025649-api into
lp:openobject-addons.
Requested reviews:
qdp (OpenERP) (qdp)
Related bugs:
Bug #1025649 in OpenERP Addons: "[Trunk] rounding issue with account taxes"
https://bugs.launchpad.net/openobject-addons/+bug/1025649
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1025649-api/+merge/137822
Method round(value, precision) changed into float_round.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1025649-api/+merge/137822
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-1025649-api.
=== modified file 'account/account.py'
--- account/account.py 2012-12-04 10:31:46 +0000
+++ account/account.py 2012-12-04 12:19:24 +0000
@@ -36,7 +36,8 @@
_logger = logging.getLogger(__name__)
def check_cycle(self, cr, uid, ids, context=None):
- """ climbs the ``self._table.parent_id`` chains for 100 levels or
+ """
+ climbs the ``self._table.parent_id`` chains for 100 levels or
until it can't find any more parent(s)
Returns true if it runs out of parents (no cycle), false if
@@ -78,11 +79,11 @@
for line in pt.line_ids:
prec = obj_precision.precision_get(cr, uid, 'Account')
if line.value == 'fixed':
- amt = round(line.value_amount, prec)
+ amt = float_round(line.value_amount, prec)
elif line.value == 'procent':
- amt = round(value * line.value_amount, prec)
+ amt = float_round(value * line.value_amount, prec)
elif line.value == 'balance':
- amt = round(amount, prec)
+ amt = float_round(amount, prec)
if amt:
next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days))
if line.days2 < 0:
@@ -1727,7 +1728,7 @@
for rec in record.child_ids:
amount += _rec_get(rec) * rec.sign
return amount
- res2[record.id] = round(_rec_get(record), obj_precision.precision_get(cr, uid, 'Account'))
+ res2[record.id] = float_round(_rec_get(record), obj_precision.precision_get(cr, uid, 'Account'))
return res2
def _sum_year(self, cr, uid, ids, name, args, context=None):
@@ -2128,9 +2129,9 @@
total = 0.0
for r in res:
if r.get('balance',False):
- r['amount'] = round(r.get('balance', 0.0) * quantity, precision) - total
+ r['amount'] = float_round(r.get('balance', 0.0) * quantity, precision) - total
else:
- r['amount'] = round(r.get('amount', 0.0) * quantity, precision)
+ r['amount'] = float_round(r.get('amount', 0.0) * quantity, precision)
total += r['amount']
return res
@@ -2224,9 +2225,9 @@
total = 0.0
for r in res:
if r.get('balance',False):
- r['amount'] = round(r['balance'] * quantity, precision) - total
+ r['amount'] = float_round(r['balance'] * quantity, precision) - total
else:
- r['amount'] = round(r['amount'] * quantity, precision)
+ r['amount'] = float_round(r['amount'] * quantity, precision)
total += r['amount']
return res
=== modified file 'account/account_analytic_line.py'
--- account/account_analytic_line.py 2012-11-29 22:26:45 +0000
+++ account/account_analytic_line.py 2012-12-04 12:19:24 +0000
@@ -22,6 +22,7 @@
from osv import fields
from osv import osv
from tools.translate import _
+from tools.float_utils import float_round
class account_analytic_line(osv.osv):
_inherit = 'account.analytic.line'
@@ -121,7 +122,7 @@
amount_unit = prod.price_get(pricetype.field, context=ctx)[prod.id]
prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
amount = amount_unit * quantity or 0.0
- result = round(amount, prec)
+ result = float_round(amount, prec)
if not flag:
result *= -1
return {'value': {
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2012-12-04 10:31:46 +0000
+++ account/account_invoice.py 2012-12-04 12:19:24 +0000
@@ -27,6 +27,7 @@
import pooler
from osv import fields, osv, orm
from tools.translate import _
+from tools.float_utils import float_round
class account_invoice(osv.osv):
def _amount_all(self, cr, uid, ids, name, args, context=None):
@@ -1306,7 +1307,7 @@
total += (l.debit or 0.0) - (l.credit or 0.0)
inv_id, name = self.name_get(cr, uid, [invoice.id], context=context)[0]
- if (not round(total,self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))) or writeoff_acc_id:
+ if (not float_round(total,self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))) or writeoff_acc_id:
self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context)
else:
code = invoice.currency_id.symbol
=== modified file 'account_analytic_analysis/account_analytic_analysis.py'
--- account_analytic_analysis/account_analytic_analysis.py 2012-11-29 22:26:45 +0000
+++ account_analytic_analysis/account_analytic_analysis.py 2012-12-04 12:19:24 +0000
@@ -24,6 +24,7 @@
import tools.sql
from tools.translate import _
from decimal_precision import decimal_precision as dp
+from tools.float_utils import float_round
class account_analytic_account(osv.osv):
@@ -95,7 +96,7 @@
# sum both result on account_id
for id in ids:
- res[id][f] = round(res.get(id, {}).get(f, 0.0), dp) + round(res2.get(id, 0.0), 2)
+ res[id][f] = float_round(res.get(id, {}).get(f, 0.0), dp) + float_round(res2.get(id, 0.0), 2)
elif f == 'last_invoice_date':
for id in ids:
res[id][f] = False
@@ -139,9 +140,9 @@
for account_id, sua in cr.fetchall():
if account_id not in res:
res[account_id] = {}
- res[account_id][f] = round(sua, dp)
+ res[account_id][f] = float_round(sua, dp)
for id in ids:
- res[id][f] = round(res[id][f], dp)
+ res[id][f] = float_round(res[id][f], dp)
elif f == 'hours_quantity':
for id in ids:
res[id][f] = 0.0
@@ -157,9 +158,9 @@
for account_id, hq in ff:
if account_id not in res:
res[account_id] = {}
- res[account_id][f] = round(hq, dp)
+ res[account_id][f] = float_round(hq, dp)
for id in ids:
- res[id][f] = round(res[id][f], dp)
+ res[id][f] = float_round(res[id][f], dp)
elif f == 'ca_theorical':
# TODO Take care of pricelist and purchase !
for id in ids:
@@ -188,7 +189,7 @@
AND account_analytic_journal.type IN ('purchase', 'general')
GROUP BY account_analytic_line.account_id""",(parent_ids,))
for account_id, sum in cr.fetchall():
- res[account_id][f] = round(sum, dp)
+ res[account_id][f] = float_round(sum, dp)
return res
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
@@ -209,7 +210,7 @@
AND account_analytic_journal.type = 'sale' \
GROUP BY account_analytic_line.account_id", (child_ids,))
for account_id, sum in cr.fetchall():
- res[account_id] = round(sum,2)
+ res[account_id] = float_round(sum,2)
res_final = res
return res_final
@@ -230,7 +231,7 @@
AND amount<0 \
GROUP BY account_analytic_line.account_id""",(child_ids,))
for account_id, sum in cr.fetchall():
- res[account_id] = round(sum,2)
+ res[account_id] = float_round(sum,2)
res_final = res
return res_final
@@ -242,7 +243,7 @@
else:
res[account.id] = 0.0
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
def _remaining_hours_to_invoice_calc(self, cr, uid, ids, name, arg, context=None):
@@ -258,7 +259,7 @@
if res[account.id] < 0:
res[account.id] = 0.0
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
def _revenue_per_hour_calc(self, cr, uid, ids, name, arg, context=None):
@@ -269,7 +270,7 @@
else:
res[account.id] = account.ca_invoiced / account.hours_qtt_invoiced
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
def _real_margin_rate_calc(self, cr, uid, ids, name, arg, context=None):
@@ -282,7 +283,7 @@
else:
res[account.id] = 0.0
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
def _fix_price_to_invoice_calc(self, cr, uid, ids, name, arg, context=None):
@@ -323,7 +324,7 @@
for account in self.browse(cr, uid, ids, context=context):
res[account.id] = account.ca_invoiced + account.total_cost
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None):
@@ -331,7 +332,7 @@
for account in self.browse(cr, uid, ids, context=context):
res[account.id] = account.ca_theorical + account.total_cost
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
def _is_overdue_quantity(self, cr, uid, ids, fieldnames, args, context=None):
@@ -508,7 +509,7 @@
for sum_id, unit_amount in cr.fetchall():
res[sum_id] = unit_amount
for id in ids:
- res[id] = round(res.get(id, 0.0), 2)
+ res[id] = float_round(res.get(id, 0.0), 2)
return res
_columns = {
=== modified file 'analytic_user_function/analytic_user_function.py'
--- analytic_user_function/analytic_user_function.py 2012-11-29 22:26:45 +0000
+++ analytic_user_function/analytic_user_function.py 2012-12-04 12:19:24 +0000
@@ -22,6 +22,7 @@
from osv import fields,osv
from tools.translate import _
import decimal_precision as dp
+from tools.float_utils import float_round
class analytic_user_funct_grid(osv.osv):
_name="analytic.user.funct.grid"
@@ -112,7 +113,7 @@
amount_unit = self.on_change_unit_amount(cr, uid, ids,
r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount']
amount = unit_amount * amount_unit
- res ['value']['amount']= - round(amount, 2)
+ res ['value']['amount']= - float_round(amount, 2)
res ['value']['general_account_id']= a
return res
@@ -142,7 +143,7 @@
r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount']
amount = unit_amount * amount_unit
- res ['value']['amount']= - round(amount, 2)
+ res ['value']['amount']= - float_round(amount, 2)
res ['value']['general_account_id']= a
return res
=== modified file 'base_calendar/base_calendar.py'
--- base_calendar/base_calendar.py 2012-11-29 22:26:45 +0000
+++ base_calendar/base_calendar.py 2012-12-04 12:19:24 +0000
@@ -30,6 +30,7 @@
import re
import time
import tools
+from tools.float_utils import float_round
months = {
1: "January", 2: "February", 3: "March", 4: "April", \
@@ -932,7 +933,7 @@
end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
diff = end - start
duration = float(diff.days)* 24 + (float(diff.seconds) / 3600)
- value['duration'] = round(duration, 2)
+ value['duration'] = float_round(duration, 2)
elif not end_date:
end = start + timedelta(hours=duration)
value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S")
@@ -943,7 +944,7 @@
end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
diff = end - start
duration = float(diff.days)* 24 + (float(diff.seconds) / 3600)
- value['duration'] = round(duration, 2)
+ value['duration'] = float_round(duration, 2)
return {'value': value}
=== modified file 'hr_attendance/report/attendance_by_month.py'
--- hr_attendance/report/attendance_by_month.py 2012-11-29 22:26:45 +0000
+++ hr_attendance/report/attendance_by_month.py 2012-12-04 12:19:24 +0000
@@ -32,13 +32,14 @@
from tools import ustr
from tools.translate import _
from tools import to_xml
+from tools.float_utils import float_round
one_day = relativedelta(days=1)
month2name = [0, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
def hour2str(h):
hours = int(h)
- minutes = int(round((h - hours) * 60, 0))
+ minutes = int(float_round((h - hours) * 60, 0))
return '%02dh%02d' % (hours, minutes)
def lengthmonth(year, month):
=== modified file 'hr_attendance/report/timesheet.py'
--- hr_attendance/report/timesheet.py 2012-11-29 22:26:45 +0000
+++ hr_attendance/report/timesheet.py 2012-12-04 12:19:24 +0000
@@ -30,12 +30,13 @@
from report import report_sxw
from tools.translate import _
import tools
+from tools.float_utils import float_round
one_week = relativedelta(days=7)
num2day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
def to_hour(h):
- return int(h), int(round((h - int(h)) * 60, 0))
+ return int(h), int(float_round((h - int(h)) * 60, 0))
class report_custom(report_rml):
=== modified file 'hr_timesheet_invoice/hr_timesheet_invoice.py'
--- hr_timesheet_invoice/hr_timesheet_invoice.py 2012-11-29 22:26:45 +0000
+++ hr_timesheet_invoice/hr_timesheet_invoice.py 2012-12-04 12:19:24 +0000
@@ -23,6 +23,7 @@
from osv import fields, osv
from tools.translate import _
+from tools.float_utils import float_round
class hr_timesheet_invoice_factor(osv.osv):
_name = "hr_timesheet_invoice.factor"
@@ -59,7 +60,7 @@
res.setdefault(account.id, 0.0)
res[account.id] += invoice.amount_untaxed
for id in ids:
- res[id] = round(res.get(id, 0.0),2)
+ res[id] = float_round(res.get(id, 0.0),2)
return res
=== modified file 'hr_timesheet_invoice/report/account_analytic_profit.py'
--- hr_timesheet_invoice/report/account_analytic_profit.py 2012-11-29 22:26:45 +0000
+++ hr_timesheet_invoice/report/account_analytic_profit.py 2012-12-04 12:19:24 +0000
@@ -21,6 +21,7 @@
from report import report_sxw
import pooler
+from tools.float_utils import float_round
class account_analytic_profit(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -84,7 +85,7 @@
price=0.0
if id not in res:
res[id]={'name': name, 'amount': 0, 'cost':0, 'unit_amount':0,'amount_th':0}
- xxx = round(price * line.unit_amount * (1-(discount or 0.0)), 2)
+ xxx = float_round(price * line.unit_amount * (1-(discount or 0.0)), 2)
res[id]['amount_th']+=xxx
if line.invoice_id:
self.cr.execute('select id from account_analytic_line where invoice_id=%s', (line.invoice_id.id,))
=== modified file 'l10n_be_coda/l10n_be_coda.py'
--- l10n_be_coda/l10n_be_coda.py 2012-11-29 22:26:45 +0000
+++ l10n_be_coda/l10n_be_coda.py 2012-12-04 12:19:24 +0000
@@ -23,6 +23,7 @@
from osv import osv, fields
import decimal_precision as dp
from tools.translate import _
+from tools.float_utils import float_round
class coda_bank_account(osv.osv):
_name= 'coda.bank.account'
@@ -235,7 +236,7 @@
for line in statement.line_ids:
res[statement.id] += line.amount
for r in res:
- res[r] = round(res[r], 2)
+ res[r] = float_round(res[r], 2)
return res
def _get_period(self, cr, uid, context=None):
=== modified file 'l10n_ch/wizard/bvr_import.py'
--- l10n_ch/wizard/bvr_import.py 2012-11-29 22:26:45 +0000
+++ l10n_ch/wizard/bvr_import.py 2012-12-04 12:19:24 +0000
@@ -26,6 +26,7 @@
from osv import osv, fields
from tools import mod10r
import pooler
+from tools.float_utils import float_round
def _reconstruct_invoice_ref(cursor, user, reference, context=None):
###
@@ -102,8 +103,8 @@
amount *= -1
cost *= -1
- if round(amount - total_amount, 2) >= 0.01 \
- or round(cost - total_cost, 2) >= 0.01:
+ if float_round(amount - total_amount, 2) >= 0.01 \
+ or float_round(cost - total_cost, 2) >= 0.01:
raise osv.except_osv(_('Error!'),
_('Total record different from the computed.'))
if int(line[51:63]) != len(records):
@@ -162,12 +163,12 @@
partner_id = line.partner_id.id
move_id = line.move_id.id
if record['amount'] >= 0:
- if round(record['amount'] - line.debit, 2) < 0.01:
+ if float_round(record['amount'] - line.debit, 2) < 0.01:
# line2reconcile = line.id
account_id = line.account_id.id
break
else:
- if round(line.credit + record['amount'], 2) < 0.01:
+ if float_round(line.credit + record['amount'], 2) < 0.01:
# line2reconcile = line.id
account_id = line.account_id.id
break
=== modified file 'point_of_sale/point_of_sale.py'
--- point_of_sale/point_of_sale.py 2012-11-29 22:26:45 +0000
+++ point_of_sale/point_of_sale.py 2012-12-04 12:19:24 +0000
@@ -35,6 +35,7 @@
from tools.translate import _
from decimal import Decimal
import decimal_precision as dp
+from tools.float_utils import float_round
_logger = logging.getLogger(__name__)
@@ -988,11 +989,11 @@
computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit * (100.0-line.discount) / 100.0, line.qty)['taxes']
for tax in computed_taxes:
- tax_amount += round(tax['amount'], 2)
+ tax_amount += float_round(tax['amount'], 2)
group_key = (tax['tax_code_id'], tax['base_code_id'], tax['account_collected_id'], tax['id'])
group_tax.setdefault(group_key, 0)
- group_tax[group_key] += round(tax['amount'], 2)
+ group_tax[group_key] += float_round(tax['amount'], 2)
amount = line.price_subtotal
=== modified file 'project/project.py'
--- project/project.py 2012-11-30 17:11:30 +0000
+++ project/project.py 2012-12-04 12:19:24 +0000
@@ -29,6 +29,7 @@
from openerp.addons.resource.faces import task as Task
from tools.translate import _
from openerp import SUPERUSER_ID
+from tools.float_utils import float_round
_TASK_STATE = [('draft', 'New'),('open', 'In Progress'),('pending', 'Pending'), ('done', 'Done'), ('cancelled', 'Cancelled')]
@@ -167,7 +168,7 @@
# compute progress rates
for id in ids:
if res[id]['total_hours']:
- res[id]['progress_rate'] = round(100.0 * res[id]['effective_hours'] / res[id]['total_hours'], 2)
+ res[id]['progress_rate'] = float_round(100.0 * res[id]['effective_hours'] / res[id]['total_hours'], 2)
else:
res[id]['progress_rate'] = 0.0
return res
@@ -673,7 +674,7 @@
res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours
res[task.id]['progress'] = 0.0
if (task.remaining_hours + hours.get(task.id, 0.0)):
- res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 99.99),2)
+ res[task.id]['progress'] = float_round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 99.99),2)
if task.state in ('done','cancelled'):
res[task.id]['progress'] = 100.0
return res
=== modified file 'project_long_term/project_long_term.py'
--- project_long_term/project_long_term.py 2012-11-29 22:26:45 +0000
+++ project_long_term/project_long_term.py 2012-12-04 12:19:24 +0000
@@ -23,6 +23,7 @@
from tools.translate import _
from osv import fields, osv
from openerp.addons.resource.faces import task as Task
+from tools.float_utils import float_round
class project_phase(osv.osv):
_name = "project.phase"
@@ -96,7 +97,7 @@
if not tot:
res[phase.id] = 0.0
else:
- res[phase.id] = round(100.0 * done / tot, 2)
+ res[phase.id] = float_round(100.0 * done / tot, 2)
return res
_columns = {
=== modified file 'resource/faces/task.py'
--- resource/faces/task.py 2012-11-29 22:26:45 +0000
+++ resource/faces/task.py 2012-12-04 12:19:24 +0000
@@ -43,6 +43,8 @@
import weakref
import opcode
import new
+from tools.float_utils import float_round
+
try:
set
except NameError:
@@ -2060,7 +2062,7 @@
self._performed_resource_length))
costs /= (60.0 * self.root.calendar.working_hours_per_day)
- return round(costs, 2)
+ return float_round(costs, 2)
costs.attrib_method = True
costs.__call_completion__ = 'costs("|")'
=== modified file 'resource/resource.py'
--- resource/resource.py 2012-11-29 22:26:45 +0000
+++ resource/resource.py 2012-12-04 12:19:24 +0000
@@ -27,6 +27,7 @@
from itertools import groupby
from operator import itemgetter
+from tools.float_utils import float_round
class resource_calendar(osv.osv):
@@ -278,7 +279,7 @@
split_list = str(time_string).split('.')
hour_part = split_list[0]
mins_part = split_list[1]
- round_mins = int(round(float(mins_part) * 60,-2))
+ round_mins = int(float_round(float(mins_part) * 60,-2))
converted_string = hour_part + ':' + str(round_mins)[0:2]
return converted_string
=== modified file 'sale/sale.py'
--- sale/sale.py 2012-11-30 17:11:30 +0000
+++ sale/sale.py 2012-12-04 12:19:24 +0000
@@ -28,6 +28,7 @@
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import decimal_precision as dp
import netsvc
+from tools.float_utils import float_round
class sale_shop(osv.osv):
_name = "sale.shop"
@@ -795,7 +796,7 @@
uos_id = self._get_line_uom(cr, uid, line, context=context)
pu = 0.0
if uosqty:
- pu = round(line.price_unit * line.product_uom_qty / uosqty,
+ pu = float_round(line.price_unit * line.product_uom_qty / uosqty,
self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
fpos = line.order_id.fiscal_position or False
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account_id)
=== modified file 'sale_margin/sale_margin.py'
--- sale_margin/sale_margin.py 2012-11-29 22:26:45 +0000
+++ sale_margin/sale_margin.py 2012-12-04 12:19:24 +0000
@@ -19,6 +19,7 @@
##############################################################################
from osv import fields, osv
+from tools.float_utils import float_round
class sale_order_line(osv.osv):
_inherit = "sale.order.line"
@@ -45,9 +46,9 @@
res[line.id] = 0
if line.product_id:
if line.purchase_price:
- res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.purchase_price*line.product_uos_qty), 2)
+ res[line.id] = float_round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.purchase_price*line.product_uos_qty), 2)
else:
- res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.product_id.standard_price*line.product_uos_qty), 2)
+ res[line.id] = float_round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.product_id.standard_price*line.product_uos_qty), 2)
return res
_columns = {
=== modified file 'survey/report/survey_analysis_report.py'
--- survey/report/survey_analysis_report.py 2011-01-14 00:11:01 +0000
+++ survey/report/survey_analysis_report.py 2012-12-04 12:19:24 +0000
@@ -26,6 +26,7 @@
import tools
import time
from report import report_sxw
+from tools.float_utils import float_round
class survey_analysis(report_rml):
def create(self, cr, uid, ids, datas, context):
@@ -196,7 +197,7 @@
if cal['column_id'] == matrix_ans[mat_col][0]:
cal_count = cal['count']
if tot_res:
- percantage = round(float(cal_count)*100 / tot_res,2)
+ percantage = float_round(float(cal_count)*100 / tot_res,2)
if percantage:
rml += """<td color="#FFF435"><para style="answer_bold">""" + tools.ustr(percantage) +"% (" + tools.ustr(cal_count) + """)</para></td>"""
else:
@@ -315,7 +316,7 @@
if tot_res and res_count:
rating_weight_sum += int(col_weight[1]) * tot_res
- tot_per = round((float(tot_res) * 100) / int(res_count), 2)
+ tot_per = float_round((float(tot_res) * 100) / int(res_count), 2)
else:
tot_per = 0.0
if tot_res:
@@ -325,7 +326,7 @@
percantage = 0.00
if res_count:
- percantage = round((float(rating_weight_sum)/res_count), 2)
+ percantage = float_round((float(rating_weight_sum)/res_count), 2)
rml += """<td><para style="answer_right">""" + tools.ustr(percantage) + """</para></td>
<td><para style="answer_right">""" + tools.ustr(res_count) + """</para></td></tr>"""
rml += """</blockTable>"""
@@ -366,7 +367,7 @@
percantage = 0.00
if calc and response:
- percantage = round((float(calc)* 100) / response,2)
+ percantage = float_round((float(calc)* 100) / response,2)
if calc:
rml += """<td><para style="answer_bold">""" +tools.ustr(percantage)+"% (" + tools.ustr(calc) + """)</para></td>"""
else:
@@ -396,7 +397,7 @@
per = 0.00
if len(tot_res):
- per = round((float(total) / len(tot_res)),2)
+ per = float_round((float(total) / len(tot_res)),2)
rml+="""<tr><td><para style="answer">""" + to_xml(tools.ustr(ans.answer)) + """</para></td>
<td> <para style="Standard"> </para></td>
<td> <para style="answer">""" + tools.ustr(per) +"""</para></td>
=== modified file 'survey/report/survey_browse_response.py'
--- survey/report/survey_browse_response.py 2011-01-14 00:11:01 +0000
+++ survey/report/survey_browse_response.py 2012-12-04 12:19:24 +0000
@@ -25,6 +25,7 @@
from tools import to_xml
import tools
import time
+from tools.float_utils import float_round
from report import report_sxw
class survey_browse_response(report_rml):
@@ -318,7 +319,7 @@
divide_list = divide_list(answer_choice,_display_ans_in_rows)
for lst in divide_list:
if que.type == 'multiple_choice_multiple_ans':
- if len(lst) <> 0 and len(lst) <> int(round(float(len(answer_choice)) / _display_ans_in_rows, 0)):
+ if len(lst) <> 0 and len(lst) <> int(float_round(float(len(answer_choice)) / _display_ans_in_rows, 0)):
lst.append('')
if not lst:
del divide_list[divide_list.index(lst):]
@@ -445,7 +446,7 @@
tmp = cols_widhts[i]
sum += col
i += 1
- cols_widhts.append(round(tmp, 2))
+ cols_widhts.append(float_round(tmp, 2))
colWidths = "cm,".join(map(tools.ustr, cols_widhts))
colWidths = colWidths + 'cm'
matrix_ans = [(0, ''),]
=== modified file 'survey/report/survey_form.py'
--- survey/report/survey_form.py 2011-01-14 00:11:01 +0000
+++ survey/report/survey_form.py 2012-12-04 12:19:24 +0000
@@ -24,6 +24,7 @@
from report.interface import report_rml
from tools import to_xml
import tools
+from tools.float_utils import float_round
class survey_form(report_rml):
def create(self, cr, uid, ids, datas, context):
@@ -204,7 +205,7 @@
divide_list = divide_list(answer,_display_ans_in_rows)
for lst in divide_list:
if que.type == 'multiple_choice_multiple_ans':
- if len(lst)<>0 and len(lst)<>int(round(float(len(answer))/_display_ans_in_rows,0)):
+ if len(lst)<>0 and len(lst)<>int(float_round(float(len(answer))/_display_ans_in_rows,0)):
lst.append('')
if not lst:
del divide_list[divide_list.index(lst):]
@@ -263,7 +264,7 @@
tmp = cols_widhts[i]
sum += col
i += 1
- cols_widhts.append(round(tmp,2))
+ cols_widhts.append(float_round(tmp,2))
colWidths = "cm,".join(map(tools.ustr, cols_widhts))
colWidths = colWidths+'cm'
matrix_ans = ['',]
=== modified file 'survey/survey.py'
--- survey/survey.py 2012-11-29 22:26:45 +0000
+++ survey/survey.py 2012-12-04 12:19:24 +0000
@@ -30,6 +30,7 @@
from dateutil.relativedelta import relativedelta
import copy
import os
+from tools.float_utils import float_round
class survey_type(osv.osv):
_name = 'survey.type'
@@ -620,7 +621,7 @@
avg = 0.0
val[rec.id] = {
'response': res[1],
- 'average': round(avg, 2),
+ 'average': float_round(avg, 2),
}
return val
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp