[FIX] product: uom creation was messing with factor and factor_inv fields
bzr revid: qdp-launchpad@tinyerp.com-20100717095656-vy3nj39ssojdnab3
This commit is contained in:
parent
94f1091622
commit
e55f77ac6a
|
@ -48,25 +48,24 @@ class product_uom(osv.osv):
|
||||||
_name = 'product.uom'
|
_name = 'product.uom'
|
||||||
_description = 'Product Unit of Measure'
|
_description = 'Product Unit of Measure'
|
||||||
|
|
||||||
|
def _compute_factor_inv(self, factor):
|
||||||
|
return factor and round(1.0 / factor, 6) or 0.0
|
||||||
|
|
||||||
def _factor_inv(self, cursor, user, ids, name, arg, context):
|
def _factor_inv(self, cursor, user, ids, name, arg, context):
|
||||||
res = {}
|
res = {}
|
||||||
for uom in self.browse(cursor, user, ids, context=context):
|
for uom in self.browse(cursor, user, ids, context=context):
|
||||||
if uom.factor:
|
res[uom.id] = self._compute_factor_inv(uom.factor)
|
||||||
res[uom.id] = round(1 / uom.factor, 6)
|
|
||||||
else:
|
|
||||||
res[uom.id] = 0.0
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _factor_inv_write(self, cursor, user, id, name, value, arg, context):
|
def _factor_inv_write(self, cursor, user, id, name, value, arg, context):
|
||||||
if value:
|
return self.write(cursor, user, id, {'factor': self._compute_factor_inv(value)}, context=context)
|
||||||
self.write(cursor, user, id, {
|
|
||||||
'factor': round(1/value, 6),
|
def create(self, cr, uid, data, context={}):
|
||||||
}, context=context)
|
if 'factor_inv' in data:
|
||||||
else:
|
if data['factor_inv'] <> 1:
|
||||||
self.write(cursor, user, id, {
|
data['factor'] = self._compute_factor_inv(data['factor_inv'])
|
||||||
'factor': 0.0,
|
del(data['factor_inv'])
|
||||||
}, context=context)
|
return super(product_uom, self).create(cr, uid, data, context)
|
||||||
return True
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Name', size=64, required=True, translate=True),
|
'name': fields.char('Name', size=64, required=True, translate=True),
|
||||||
|
@ -85,13 +84,11 @@ class product_uom(osv.osv):
|
||||||
"Use 1.0 for a UoM that cannot be further split, such as a piece."),
|
"Use 1.0 for a UoM that cannot be further split, such as a piece."),
|
||||||
'active': fields.boolean('Active', help="By unchecking the active field you can disable a unit of measure without deleting it."),
|
'active': fields.boolean('Active', help="By unchecking the active field you can disable a unit of measure without deleting it."),
|
||||||
'uom_type': fields.selection([('bigger','Bigger than the reference UoM'),
|
'uom_type': fields.selection([('bigger','Bigger than the reference UoM'),
|
||||||
('reference','Reference UoM for this category (ratio=1)'),
|
('reference','Reference UoM for this category'),
|
||||||
('smaller','Smaller than the reference UoM')],'UoM Type', required=1),
|
('smaller','Smaller than the reference UoM')],'UoM Type', required=1),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'factor': 1.0,
|
|
||||||
'factor_inv': 1.0,
|
|
||||||
'active': 1,
|
'active': 1,
|
||||||
'rounding': 0.01,
|
'rounding': 0.01,
|
||||||
'uom_type': 'reference',
|
'uom_type': 'reference',
|
||||||
|
|
Loading…
Reference in New Issue