2013/7/15 Giedrius Slavinskas <[email protected]> > 2013/7/15 Guillem Barba Domingo <[email protected]> > >> Hi, related to the poll about bew methods in UoM instances, I found >> confusing the names of parameters of compute_qty/price claamethods of UOM >> (really, I think it's wrong). >> >> The signature is compute_qty(from_uom, qty, to_uom, round) >> > It is a good signature for a classmethod (basically a function). I don't > see a benefit of changing something here. > >> But it does the next conversion: >> "qty" of "to_UoM" => "from_UoM" >> > No, it converts in the oppositive way: "qty" of "from_uom" => "to_uom". >
My fault, the problem is not in compute_qty() method but in compute_price(). You can see an example in test0050uom_compute_price() [1] The error is that, as well as in compute_qty() the 'factor' of 'from_uom' is multiplied [2], in compute_price() it is divided [3]. The same for 'rate' fields and 'to_uom' param. As the error is only in one method, the solution of simply swap the parameter names (to mantain positional params) don't make sense, so the method and tests must to be fixed and changed all modules that use it. [1] http://hg.tryton.org/modules/product/file/d10ea66a0602/tests/test_product.py#l172 [2] http://hg.tryton.org/modules/product/file/d10ea66a0602/uom.py#l202 [3] http://hg.tryton.org/modules/product/file/d10ea66a0602/uom.py#l227 -- Guillem Barba http://www.guillem.alcarrer.net
