diff --git a/CHANGELOG b/CHANGELOG
index a6ea64f3b0..3513822d2d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Open product quantities by warehouse to show moves
+
Version 5.2.0 - 2019-05-06
* Bug fixes (see mercurial logs for details)
* Don't set default unit price on stock move
diff --git a/__init__.py b/__init__.py
index 1aee34cdf4..9548825e73 100644
--- a/__init__.py
+++ b/__init__.py
@@ -2,61 +2,66 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
-from .location import *
-from .shipment import *
-from .period import *
-from .move import *
-from .product import *
+from . import location
+from . import shipment
+from . import period
+from . import move
+from . import product
from . import inventory
-from .configuration import *
+from . import configuration
from . import party
+from .move import StockMixin
+
+__all__ = ['StockMixin', 'register']
+
def register():
Pool.register(
- Location,
- Party,
- PartyLocation,
- ProductsByLocationsContext,
- LocationLeadTime,
- Move,
- ShipmentIn,
- ShipmentInReturn,
- ShipmentOut,
- ShipmentOutReturn,
- AssignShipmentOutAssignFailed,
- ShipmentInternal,
- Address,
- AssignShipmentInternalAssignFailed,
- AssignShipmentInReturnAssignFailed,
- Period,
- Cache,
- Template,
- Product,
- ProductByLocationContext,
- ProductQuantitiesByWarehouse,
- ProductQuantitiesByWarehouseContext,
+ location.Location,
+ location.Party,
+ location.PartyLocation,
+ location.ProductsByLocationsContext,
+ location.LocationLeadTime,
+ move.Move,
+ shipment.ShipmentIn,
+ shipment.ShipmentInReturn,
+ shipment.ShipmentOut,
+ shipment.ShipmentOutReturn,
+ shipment.AssignShipmentOutAssignFailed,
+ shipment.ShipmentInternal,
+ shipment.Address,
+ shipment.AssignShipmentInternalAssignFailed,
+ shipment.AssignShipmentInReturnAssignFailed,
+ period.Period,
+ period.Cache,
+ product.Template,
+ product.Product,
+ product.ProductByLocationContext,
+ product.ProductQuantitiesByWarehouse,
+ product.ProductQuantitiesByWarehouseContext,
inventory.Inventory,
inventory.InventoryLine,
inventory.CountSearch,
inventory.CountQuantity,
- Configuration,
- ConfigurationSequence,
- ConfigurationLocation,
+ configuration.Configuration,
+ configuration.ConfigurationSequence,
+ configuration.ConfigurationLocation,
module='stock', type_='model')
Pool.register(
- AssignShipmentOut,
- AssignShipmentInternal,
- AssignShipmentInReturn,
- RecomputeCostPrice,
+ shipment.AssignShipmentOut,
+ shipment.AssignShipmentInternal,
+ shipment.AssignShipmentInReturn,
+ product.OpenProductQuantitiesByWarehouse,
+ product.RecomputeCostPrice,
inventory.Count,
party.PartyReplace,
party.PartyErase,
module='stock', type_='wizard')
Pool.register(
- DeliveryNote,
- PickingList,
- SupplierRestockingList,
- CustomerReturnRestockingList,
- InteralShipmentReport,
+ shipment.DeliveryNote,
+ shipment.PickingList,
+ shipment.SupplierRestockingList,
+ shipment.CustomerReturnRestockingList,
+ shipment.InteralShipmentReport,
module='stock', type_='report')
diff --git a/product.py b/product.py
index e77a25ed6b..7b78956b67 100644
--- a/product.py
+++ b/product.py
@@ -13,8 +13,8 @@ from sql.conditionals import Coalesce
from trytond.i18n import gettext
from trytond.model import ModelSQL, ModelView, fields
from trytond.model.exceptions import AccessError
-from trytond.wizard import Wizard, StateTransition
-from trytond.pyson import Eval, Or
+from trytond.wizard import Wizard, StateTransition, StateAction
+from trytond.pyson import Eval, Or, PYSONEncoder
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.tools import grouped_slice
@@ -426,6 +426,32 @@ class ProductQuantitiesByWarehouse(ModelSQL, ModelView):
return dict((l.id, quantities[l.date]) for l in lines)
+ @classmethod
+ def get_rec_name(cls, records, name):
+ pool = Pool()
+ Lang = pool.get('ir.lang')
+ Product = pool.get('product.product')
+ Template = pool.get('product.template')
+ Location = pool.get('stock.location')
+ context = Transaction().context
+
+ if context.get('product_template'):
+ name = Template(context['product_template']).rec_name
+ elif context.get('product'):
+ name = Product(context['product']).rec_name
+ else:
+ name = ''
+ if context.get('warehouse'):
+ warehouse_name = Location(context['warehouse']).rec_name
+ else:
+ warehouse_name = '-'
+ lang = Lang.get()
+ names = {}
+ for record in records:
+ names[record.id] = '%s (%s) @ %s' % (
+ name, warehouse_name, lang.strftime(record.date))
+ return names
+
class ProductQuantitiesByWarehouseContext(ModelView):
'Product Quantities By Warehouse'
@@ -446,6 +472,55 @@ class ProductQuantitiesByWarehouseContext(ModelView):
return warehouses[0].id
+class OpenProductQuantitiesByWarehouse(Wizard):
+ "Open Product Quantities By Warehouse"
+ __name__ = 'stock.product_quantities_warehouse.open'
+ start_state = 'open_'
+ open_ = StateAction('stock.act_move_form')
+
+ def do_open_(self, action):
+ pool = Pool()
+ Date = pool.get('ir.date')
+ ProductQuantitiesByWarehouse = pool.get(
+ 'stock.product_quantities_warehouse')
+ context = Transaction().context
+ today = Date.today()
+
+ record = ProductQuantitiesByWarehouse(context['active_id'])
+ warehouse_id = context.get('warehouse', -1)
+ domain = [
+ ['OR',
+ [
+ ('from_location', 'child_of', [warehouse_id], 'parent'),
+ ('to_location', 'not child_of', [warehouse_id], 'parent'),
+ ],
+ [
+ ('to_location', 'child_of', [warehouse_id], 'parent'),
+ ('from_location', 'not child_of',
+ [warehouse_id], 'parent'),
+ ],
+ ],
+ ['OR',
+ ('effective_date', '=', record.date),
+ [
+ ('effective_date', '=', None),
+ ('planned_date', '=', record.date),
+ ],
+ ],
+ ]
+ if record.date < today:
+ domain.append(('state', '=', 'done'))
+ if context.get('product_template'):
+ domain.append(
+ ('product.template', '=', context['product_template']))
+ else:
+ domain.append(('product', '=', context.get('product', -1)))
+ action['pyson_domain'] = PYSONEncoder().encode(domain)
+ action['pyson_search_value'] = None
+ action['name'] += ' (' + record.rec_name + ')'
+ return action, {}
+
+
class RecomputeCostPrice(Wizard):
'Recompute Cost Price'
__name__ = 'product.recompute_cost_price'
diff --git a/product.xml b/product.xml
index cf373dd5c8..e03bf7a678 100644
--- a/product.xml
+++ b/product.xml
@@ -157,6 +157,16 @@ this repository contains the full copyright notices and license terms. -->
product_quantities_warehouse_context_form
+
+ Stock Moves
+ stock.product_quantities_warehouse.open
+
+
+ tree_open
+ stock.product_quantities_warehouse,-1
+
+
+
form_relate
diff --git a/view/product_quantities_warehouse_list.xml b/view/product_quantities_warehouse_list.xml
index 165e5aa17f..49881b5e1e 100644
--- a/view/product_quantities_warehouse_list.xml
+++ b/view/product_quantities_warehouse_list.xml
@@ -1,7 +1,7 @@
-
+