Make order point's minimal quantity required

issue8405
review259611017
This commit is contained in:
Sergi Almacellas Abellana committed 2019-06-28 10:17:10 +02:00
1 parent 6fee02212b
commit b4fbe0c357
4 files changed
+65 -1

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Make order point's minimal quantity required
Version 5.2.0 - 2019-05-06
* Bug fixes (see mercurial logs for details)
+5 -1
View File
@@ -71,11 +71,15 @@ class OrderPoint(ModelSQL, ModelView):
'Type', select=True, required=True)
min_quantity = fields.Float('Minimal Quantity',
digits=(16, Eval('unit_digits', 2)),
states={
# required for purchase and production types
'required': Eval('type') != 'internal',
},
domain=['OR',
('min_quantity', '=', None),
('min_quantity', '<=', Eval('target_quantity', 0)),
],
depends=['unit_digits', 'target_quantity'])
depends=['unit_digits', 'target_quantity', 'type'])
target_quantity = fields.Float('Target Quantity', required=True,
digits=(16, Eval('unit_digits', 2)),
domain=[
@@ -162,6 +162,63 @@ There is now a draft purchase request::
>>> pr.quantity
1.0
Create an order point with negative minimal quantity::
>>> set_user(stock_admin_user)
>>> OrderPoint = Model.get('stock.order_point')
>>> order_point = OrderPoint()
>>> order_point.type = 'purchase'
>>> order_point.product = product
>>> order_point.warehouse_location = warehouse_loc
>>> order_point.min_quantity = -1
>>> order_point.target_quantity = 10
>>> order_point.save()
Create production request::
>>> create_pr = Wizard('stock.supply')
>>> create_pr.execute('create_')
There is no more production request::
>>> set_user(purchase_user)
>>> PurchaseRequest.find([])
[]
Set a postive minimal quantity on order point create purchase request::
>>> set_user(stock_admin_user)
>>> order_point.min_quantity = 5
>>> order_point.save()
>>> create_pr = Wizard('stock.supply')
>>> create_pr.execute('create_')
There is now a draft purchase request::
>>> set_user(purchase_user)
>>> pr, = PurchaseRequest.find([('state', '=', 'draft')])
>>> pr.product == product
True
>>> pr.quantity
11.0
Using zero as minimal quantity on order point also creates purchase request::
>>> set_user(stock_admin_user)
>>> order_point.min_quantity = 0
>>> order_point.save()
>>> create_pr = Wizard('stock.supply')
>>> create_pr.execute('create_')
There is now a draft purchase request::
>>> set_user(purchase_user)
>>> pr, = PurchaseRequest.find([('state', '=', 'draft')])
>>> pr.product == product
True
>>> pr.quantity
11.0
Re-run with purchased request::
>>> create_purchase = Wizard('purchase.request.create_purchase', [pr])
+1
View File
@@ -148,6 +148,7 @@ class StockSupplyTestCase(ModuleTestCase):
'product': product.id,
'type': 'purchase',
'warehouse_location': warehouse.id,
'min_quantity': 0.0,
'target_quantity': 5.0,
}])