diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 5d56d3cb31a..d1bb845e38d 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -32,6 +32,7 @@ from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp from openerp.osv.orm import browse_record, browse_null from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP +from openerp.tools.float_utils import float_compare class purchase_order(osv.osv): @@ -1013,13 +1014,14 @@ class purchase_order_line(osv.osv): supplierinfo = False + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Unit of Measure') for supplier in product.seller_ids: if partner_id and (supplier.name.id == partner_id): supplierinfo = supplier if supplierinfo.product_uom.id != uom_id: res['warning'] = {'title': _('Warning!'), 'message': _('The selected supplier only sells this product by %s') % supplierinfo.product_uom.name } min_qty = product_uom._compute_qty(cr, uid, supplierinfo.product_uom.id, supplierinfo.min_qty, to_uom_id=uom_id) - if (qty or 0.0) < min_qty: # If the supplier quantity is greater than entered from user, set minimal. + if float_compare(min_qty , qty, precision_digits=precision) == 1: # If the supplier quantity is greater than entered from user, set minimal. if qty: res['warning'] = {'title': _('Warning!'), 'message': _('The selected supplier has a minimal quantity set to %s %s, you should not purchase less.') % (supplierinfo.min_qty, supplierinfo.product_uom.name)} qty = min_qty