diff --git a/CHANGELOG b/CHANGELOG index 8ed5eb3ff2..87bcf09529 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add entry to show lot quantities + Version 4.0.0 - 2016-05-02 * Bug fixes (see mercurial logs for details) * Add Python3 support diff --git a/__init__.py b/__init__.py index 60647e83e7..1d4845be36 100644 --- a/__init__.py +++ b/__init__.py @@ -9,6 +9,7 @@ from .product import * def register(): Pool.register( Lot, + LotByLocationContext, LotType, Move, ShipmentIn, diff --git a/stock.py b/stock.py index d1aed4bacb..9029720ae6 100644 --- a/stock.py +++ b/stock.py @@ -1,5 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +import datetime + from trytond.model import ModelView, ModelSQL, fields from trytond.pyson import Eval from trytond.pool import Pool, PoolMeta @@ -7,9 +9,9 @@ from trytond.transaction import Transaction from trytond.modules.stock import StockMixin __all__ = ['Lot', 'LotType', 'Move', 'ShipmentIn', 'ShipmentOut', - 'ShipmentOutReturn', + 'LotByLocationContext', 'ShipmentOutReturn', 'Period', 'PeriodCacheLot', - 'Inventory', 'InventoryLine'] + 'Inventory', 'InventoryLine', 'LotByLocationContext'] class Lot(ModelSQL, ModelView, StockMixin): @@ -37,6 +39,29 @@ class Lot(ModelSQL, ModelView, StockMixin): grouping=('product', 'lot')) +class LotByLocationContext(ModelView): + 'Lot by Location' + __name__ = 'stock.lots_by_location.context' + forecast_date = fields.Date( + 'At Date', help=('Allow to compute expected ' + 'stock quantities for this date.\n' + '* An empty value is an infinite date in the future.\n' + '* A date in the past will provide historical values.')) + stock_date_end = fields.Function(fields.Date('At Date'), + 'on_change_with_stock_date_end') + + @staticmethod + def default_forecast_date(): + Date = Pool().get('ir.date') + return Date.today() + + @fields.depends('forecast_date') + def on_change_with_stock_date_end(self, name=None): + if self.forecast_date is None: + return datetime.datetime.max + return self.forecast_date + + class LotType(ModelSQL, ModelView): "Stock Lot Type" __name__ = 'stock.lot.type' diff --git a/stock.xml b/stock.xml index 4b670dfc67..8952c3f27a 100644 --- a/stock.xml +++ b/stock.xml @@ -14,6 +14,12 @@ this repository contains the full copyright notices and license terms. --> tree lot_tree + + stock.lot + tree + + lot_quantity_tree + Lots @@ -48,6 +54,41 @@ this repository contains the full copyright notices and license terms. --> + + stock.lots_by_location.context + form + lot_by_location_context_form + + + + Lot + stock.lot + + + stock.lots_by_location.context + + + + + + + + + + + + + form_relate + stock.location,-1 + + + Moves stock.move diff --git a/view/lot_by_location_context_form.xml b/view/lot_by_location_context_form.xml new file mode 100644 index 0000000000..b026ccc29c --- /dev/null +++ b/view/lot_by_location_context_form.xml @@ -0,0 +1,8 @@ + + +
+