diff --git a/addons/product/product.py b/addons/product/product.py
index 7a36507aa79..ff0a6a770d7 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -132,10 +132,10 @@ class product_uom(osv.osv):
'name': fields.char('Unit of Measure', size=64, required=True, translate=True),
'category_id': fields.many2one('product.uom.categ', 'Category', required=True, ondelete='cascade',
help="Conversion between Units of Measure can only occur if they belong to the same category. The conversion will be made based on the ratios."),
- 'factor': fields.float('Ratio', required=True,digits=(12, 12),
+ 'factor': fields.float('Ratio', required=True, digits=0, # force NUMERIC with unlimited precision
help='How much bigger or smaller this unit is compared to the reference Unit of Measure for this category:\n'\
'1 * (reference unit) = ratio * (this unit)'),
- 'factor_inv': fields.function(_factor_inv, digits=(12,12),
+ 'factor_inv': fields.function(_factor_inv, digits=0, # force NUMERIC with unlimited precision
fnct_inv=_factor_inv_write,
string='Ratio',
help='How many times this Unit of Measure is bigger than the reference Unit of Measure in this category:\n'\
diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml
index 26bc294e436..7b4539e7dd3 100644
--- a/addons/product/product_view.xml
+++ b/addons/product/product_view.xml
@@ -421,8 +421,8 @@
e.g: 1 * (reference unit) = ratio * (this unit)
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index f934235d99d..dc949db16ad 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -592,7 +592,12 @@ def get_pg_type(f, type_override=None): if field_type in FIELDS_TO_PGTYPES: pg_type = (FIELDS_TO_PGTYPES[field_type], FIELDS_TO_PGTYPES[field_type]) elif issubclass(field_type, fields.float): - if f.digits: + # Explicit support for "falsy" digits (0, False) to indicate a + # NUMERIC field with no fixed precision. The values will be saved + # in the database with all significant digits. + # FLOAT8 type is still the default when there is no precision because + # it is faster for most operations (sums, etc.) + if f.digits is not None: pg_type = ('numeric', 'NUMERIC') else: pg_type = ('float8', 'DOUBLE PRECISION')