Compare quantity as absolute value and enforce positive quantities
issue7159 review44041002
This commit is contained in:
1 parent
82782cdcad
commit
b15f58579d
2 files changed
+8
-2
No files matched your search
+6
-2
@@ -334,7 +334,11 @@ class ProductSupplierPrice(
|
||||
__name__ = 'purchase.product_supplier.price'
|
||||
product_supplier = fields.Many2One('purchase.product_supplier',
|
||||
'Supplier', required=True, ondelete='CASCADE')
|
||||
quantity = fields.Float('Quantity', required=True, help='Minimal quantity')
|
||||
quantity = fields.Float(
|
||||
"Quantity",
|
||||
required=True,
|
||||
domain=[('quantity', '>=', 0)],
|
||||
help='Minimal quantity')
|
||||
unit_price = fields.Numeric('Unit Price', required=True,
|
||||
digits=price_digits)
|
||||
|
||||
@@ -367,6 +371,6 @@ class ProductSupplierPrice(
|
||||
Uom = pool.get('product.uom')
|
||||
test_quantity = Uom.compute_qty(
|
||||
self.product_supplier.uom, self.quantity, uom)
|
||||
if test_quantity > quantity:
|
||||
if test_quantity > abs(quantity):
|
||||
return False
|
||||
return super(ProductSupplierPrice, self).match(pattern)
|
||||
@@ -101,6 +101,8 @@ class PurchaseTestCase(ModuleTestCase):
|
||||
self.assertEqual(prices, {product.id: Decimal(3000)})
|
||||
prices = Product.get_purchase_price([product], quantity=3)
|
||||
self.assertEqual(prices, {product.id: Decimal(2500)})
|
||||
prices = Product.get_purchase_price([product], quantity=-4)
|
||||
self.assertEqual(prices, {product.id: Decimal(2500)})
|
||||
|
||||
|
||||
def suite():
|
||||
|
||||
Reference in new issue
Block a user