diff --git a/CHANGELOG b/CHANGELOG index 44de11f380..ffe527658f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Added stock_destinations keyword on products_by_location context to + filter moves to a set of destinations. * Allow egg installation Version 1.0.0 - 2008-11-17 diff --git a/doc/index_en.rst b/doc/index_en.rst index 677cd6caff..089587998c 100644 --- a/doc/index_en.rst +++ b/doc/index_en.rst @@ -1,10 +1,10 @@ Stock Module ############ -The stock module define fundamental for all stock management -stations: Locations where product are stored, move between these -locations, packings for product arrivals and departures and inventory to -control and update stock levels. +The stock module define fundamentals for all stock management +situations: Locations where product are stored, move between these +locations, packings for product arrivals and departures and inventory +to control and update stock levels. Location ******** diff --git a/inventory.py b/inventory.py index 3be3009228..41485b6f2b 100644 --- a/inventory.py +++ b/inventory.py @@ -282,7 +282,7 @@ InventoryLine() class CompleteInventory(Wizard): - 'Complete Inventory ' + 'Complete Inventory' _name = 'stock.inventory.complete' states = { 'init': { diff --git a/product.py b/product.py index d8b7165098..3ed8733949 100644 --- a/product.py +++ b/product.py @@ -263,6 +263,20 @@ class Product(OSV): ",".join(["%s" for i in product_ids]) + ")" where_vals += product_ids + if context.get('stock_destinations'): + destinations = context.get('stock_destinations') + dest_clause_from = " AND from_location in (" + dest_clause_from += ",".join("%s" for i in destinations) + dest_clause_from += ") " + dest_clause_to = " AND to_location in (" + dest_clause_to += ",".join("%s" for i in destinations) + dest_clause_to += ") " + dest_vals = destinations + + else: + dest_clause_from = dest_clause_to ="" + dest_vals = [] + select_clause = \ "SELECT location, product, uom, sum(quantity) AS quantity "\ "FROM ( "\ @@ -281,10 +295,11 @@ class Product(OSV): "GROUP BY from_location, product, uom "\ ") AS T GROUP BY T.location, T.product, T.uom" - cursor.execute(select_clause % (state_date_clause, where_clause, - state_date_clause, where_clause), - state_date_vals + where_vals + \ - state_date_vals + where_vals) + cursor.execute(select_clause % ( + state_date_clause, where_clause + dest_clause_from, + state_date_clause, where_clause + dest_clause_to), + state_date_vals + where_vals + dest_vals + \ + state_date_vals + where_vals + dest_vals) raw_lines = cursor.fetchall() res = {}