Merge lp:~openerp-dev/openobject-server/6.0-opw-17993-vro into lp:openobject-server/6.0

Proposed by Valencia Rodrigues (OpenERP)
Status: Merged
Merged at revision: 3521
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-17993-vro
Merge into: lp:openobject-server/6.0
Diff against target: 32 lines (+11/-1)
1 file modified
bin/addons/base/res/res_currency.py (+11/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-17993-vro
Reviewer Review Type Date Requested Status
Raphael Collet (OpenERP) Pending
Review via email: mp+78553@code.launchpad.net

Description of the change

Hello,

If the "Rounding factor" (rounding) of a currency is set to 0.0, it will nullify the value of rounded amounts.

To regenerate the issue (Case#17993):
1. Create a new currency with rounding left as 0.0
2. Use this currency in an invoice
3. Add invoice lines and observe that the Sub-total field has value 0.0 because of rounding of the currency.

This fixes the issue.

This fix also sets the rounding default to 0.01

Thanks

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/base/res/res_currency.py'
2--- bin/addons/base/res/res_currency.py 2011-07-13 15:32:10 +0000
3+++ bin/addons/base/res/res_currency.py 2011-10-07 10:04:24 +0000
4@@ -44,6 +44,13 @@
5 else:
6 res[id] = 0
7 return res
8+
9+ def _check_rounding(self, cr, uid, ids, context=None):
10+ for currency in self.browse(cr, uid, ids, context=context):
11+ if currency.rounding == 0.0:
12+ return False
13+ return True
14+
15 _name = "res.currency"
16 _description = "Currency"
17 _columns = {
18@@ -63,10 +70,13 @@
19 }
20 _defaults = {
21 'active': lambda *a: 1,
22- 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c)
23+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c),
24+ 'rounding': lambda *a: 0.01
25 }
26 _order = "name"
27
28+ _constraints = [(_check_rounding, "The rounding factor must not be 0 !",['rounding'])]
29+
30 def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
31 res=super(osv.osv, self).read(cr, user, ids, fields, context, load)
32 for r in res: