[FIX] product: creation of reference uom
authorMartin Trigaux <mat@odoo.com>
Mon, 24 Nov 2014 09:51:23 +0000 (10:51 +0100)
committerMartin Trigaux <mat@odoo.com>
Mon, 24 Nov 2014 10:04:50 +0000 (11:04 +0100)
Set a default value for factor when creating a new uom.
Could not create a new UoM with type reference (if creates a reference uom, no need to pass a factor).

Change the readonly filter to (type = bigger) to make the field writable for reference uom.
This is needed to force the reset of the factor when switching of type (onchange_type).
As the field was readonly, kept the old value for factor.

addons/product/product.py
addons/product/product_view.xml

index ce5b9ba..abdbcaf 100644 (file)
@@ -152,6 +152,7 @@ class product_uom(osv.osv):
     _defaults = {
         'active': 1,
         'rounding': 0.01,
+        'factor': 1,
         'uom_type': 'reference',
     }
 
index a59a77c..f0908dd 100644 (file)
                                 <field name="factor"
                                     digits="[42,5]"
                                     attrs="{'invisible':[('uom_type','!=','smaller')],
-                                            'readonly':[('uom_type','!=','smaller')]}"/>
+                                            'readonly':[('uom_type','=','bigger')]}"/>
                                 <field name="factor_inv"
                                     digits="[42,5]"
                                     attrs="{'invisible':[('uom_type','!=','bigger')],