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
=== modified file 'bin/addons/base/res/res_currency.py'
--- bin/addons/base/res/res_currency.py 2011-07-13 15:32:10 +0000
+++ bin/addons/base/res/res_currency.py 2011-10-07 10:04:24 +0000
@@ -44,6 +44,13 @@
44 else:44 else:
45 res[id] = 045 res[id] = 0
46 return res46 return res
47
48 def _check_rounding(self, cr, uid, ids, context=None):
49 for currency in self.browse(cr, uid, ids, context=context):
50 if currency.rounding == 0.0:
51 return False
52 return True
53
47 _name = "res.currency"54 _name = "res.currency"
48 _description = "Currency"55 _description = "Currency"
49 _columns = {56 _columns = {
@@ -63,10 +70,13 @@
63 }70 }
64 _defaults = {71 _defaults = {
65 'active': lambda *a: 1,72 'active': lambda *a: 1,
66 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c)73 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c),
74 'rounding': lambda *a: 0.01
67 }75 }
68 _order = "name"76 _order = "name"
6977
78 _constraints = [(_check_rounding, "The rounding factor must not be 0 !",['rounding'])]
79
70 def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):80 def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
71 res=super(osv.osv, self).read(cr, user, ids, fields, context, load)81 res=super(osv.osv, self).read(cr, user, ids, fields, context, load)
72 for r in res:82 for r in res: