summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>2012-09-24 16:54:24 +0200
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>2012-09-24 16:54:24 +0200
commit45a496889352fb68bf0f5ae2b9c4fdd25865a211 (patch)
tree2e9315161af02bc77e0ff69aebe733061b899454
parent4488c42ee532cb6715d986764f5532f26476cd25 (diff)
parent29badc35a54e00f0ca0d516473eb82016d2b9355 (diff)
[MERGE] merged the branch that adds constraints to ensure that the decimal precision of 'Account' is always greater than the rounding factor of the company's main currency
bzr revid: qdp-launchpad@openerp.com-20120924145424-qvomag5x4nhpru6o
-rw-r--r--addons/product/product.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/addons/product/product.py b/addons/product/product.py
index ab282e722c0..df0ab9122c2 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -897,4 +897,43 @@ class pricelist_partnerinfo(osv.osv):
}
_order = 'min_quantity asc'
pricelist_partnerinfo()
+
+class res_currency(osv.osv):
+ _inherit = 'res.currency'
+
+ def _check_main_currency_rounding(self, cr, uid, ids, context=None):
+ cr.execute('SELECT digits FROM decimal_precision WHERE name like %s',('Account',))
+ digits = cr.fetchone()
+ if digits and len(digits):
+ digits = digits[0]
+ main_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id
+ for currency_id in ids:
+ if currency_id == main_currency.id:
+ if main_currency.rounding < 10 ** -digits:
+ return False
+ return True
+
+ _constraints = [
+ (_check_main_currency_rounding, 'Error! You cannot define a rounding factor for the company\'s main currency that is smaller than the decimal precision of \'Account\'.', ['rounding']),
+ ]
+
+class decimal_precision(osv.osv):
+ _inherit = 'decimal.precision'
+
+ def _check_main_currency_rounding(self, cr, uid, ids, context=None):
+ cr.execute('SELECT id, digits FROM decimal_precision WHERE name like %s',('Account',))
+ res = cr.fetchone()
+ if res and len(res):
+ account_precision_id, digits = res
+ main_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id
+ for decimal_precision in ids:
+ if decimal_precision == account_precision_id:
+ if main_currency.rounding < 10 ** -digits:
+ return False
+ return True
+
+ _constraints = [
+ (_check_main_currency_rounding, 'Error! You cannot define the decimal precision of \'Account\' as greater than the rounding factor of the company\'s main currency', ['digits']),
+ ]
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: