trytond-patches/issue240_631.diff

317 lines
10 KiB
Diff

diff -r e6dfc508d927 trytond/trytond/modules/stock_lot/__init__.py
--- a/trytond/trytond/modules/stock_lot/__init__.py Sat Nov 12 00:18:55 2016 +0100
+++ b/trytond/trytond/modules/stock_lot/__init__.py Thu Dec 15 23:48:12 2016 +0100
@@ -21,4 +21,9 @@
Template,
Product,
TemplateLotType,
+ Location,
+ LotByLocationStart,
module='stock_lot', type_='model')
+ Pool.register(
+ LotByLocation,
+ module='stock_lot', type_='wizard')
diff -r e6dfc508d927 trytond/trytond/modules/stock_lot/stock.py
--- a/trytond/trytond/modules/stock_lot/stock.py Sat Nov 12 00:18:55 2016 +0100
+++ b/trytond/trytond/modules/stock_lot/stock.py Thu Dec 15 23:48:12 2016 +0100
@@ -1,17 +1,20 @@
# 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 collections import defaultdict
from trytond.model import ModelView, ModelSQL, fields
-from trytond.pyson import Eval
+from trytond.pyson import Eval, PYSONEncoder
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
+from trytond.wizard import Wizard, StateView, StateAction, Button
from trytond.modules.stock import StockMixin
__all__ = ['Lot', 'LotType', 'Move', 'ShipmentIn', 'ShipmentOut',
'ShipmentOutReturn',
'Period', 'PeriodCacheLot',
- 'Inventory', 'InventoryLine']
+ 'Inventory', 'InventoryLine', 'Location', 'LotByLocationStart',
+ 'LotByLocation']
__metaclass__ = PoolMeta
@@ -211,3 +214,73 @@
if move:
move.lot = self.lot
return move
+
+
+class Location:
+ __name__ = 'stock.location'
+
+ @classmethod
+ def _quantity_grouping_and_key(cls):
+ if Transaction().context.get('lot'):
+ lot_id = Transaction().context['lot']
+ product_id = Transaction().context['product']
+ return ('product', 'lot'), (product_id, lot_id)
+ return super(Location, cls)._quantity_grouping_and_key()
+
+
+class LotByLocationStart(ModelView):
+ 'Lot by Location'
+ __name__ = 'stock.lot.by_location.start'
+ 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.'))
+
+ @staticmethod
+ def default_forecast_date():
+ Date = Pool().get('ir.date')
+ return Date.today()
+
+
+class LotByLocation(Wizard):
+ 'Lot by Location'
+ __name__ = 'stock.lot.by_location'
+ start = StateView('stock.lot.by_location.start',
+ 'stock_lot.lot_by_location_start_view_form', [
+ Button('Cancel', 'end', 'tryton-cancel'),
+ Button('Open', 'open', 'tryton-ok', default=True),
+ ])
+ open = StateAction('stock.act_location_quantity_tree')
+
+ def do_open(self, action):
+ pool = Pool()
+ Lot = pool.get('stock.lot')
+ Lang = pool.get('ir.lang')
+
+ context = {}
+ lot_id = Transaction().context['active_id']
+ context['lot'] = lot_id
+
+ lot = Lot(lot_id)
+ context['product'] = lot.product.id
+
+ if self.start.forecast_date:
+ context['stock_date_end'] = self.start.forecast_date
+ else:
+ context['stock_date_end'] = datetime.date.max
+ action['pyson_context'] = PYSONEncoder().encode(context)
+
+ for code in [Transaction().language, 'en_US']:
+ langs = Lang.search([
+ ('code', '=', code),
+ ])
+ if langs:
+ break
+ lang, = langs
+ date = Lang.strftime(context['stock_date_end'],
+ lang.code, lang.date)
+
+ action['name'] += ' - %s (%s) @ %s' % (lot.rec_name,
+ lot.product.default_uom.rec_name, date)
+ return action, {}
diff -r e6dfc508d927 trytond/trytond/modules/stock_lot/stock.xml
--- a/trytond/trytond/modules/stock_lot/stock.xml Sat Nov 12 00:18:55 2016 +0100
+++ b/trytond/trytond/modules/stock_lot/stock.xml Thu Dec 15 23:48:12 2016 +0100
@@ -62,6 +62,28 @@
<field name="action" ref="act_move_form_relate_lot"/>
</record>
+ <record model="ir.action.wizard" id="wizard_lot_by_location">
+ <field name="name">Lot by Locations</field>
+ <field name="wiz_name">stock.lot.by_location</field>
+ <field name="model">stock.lot</field>
+ </record>
+ <record model="ir.action.keyword" id="act_location_quantity_keyword1">
+ <field name="keyword">form_relate</field>
+ <field name="model">stock.lot,-1</field>
+ <field name="action" ref="wizard_lot_by_location"/>
+ </record>
+ <record model="ir.action-res.group"
+ id="wizard_lot_by_location-group_stock">
+ <field name="action" ref="wizard_lot_by_location"/>
+ <field name="group" ref="stock.group_stock"/>
+ </record>
+
+ <record model="ir.ui.view" id="lot_by_location_start_view_form">
+ <field name="model">stock.lot.by_location.start</field>
+ <field name="type">form</field>
+ <field name="name">lot_by_location_start_form</field>
+ </record>
+
<record model="stock.lot.type" id="type_supplier">
<field name="code">supplier</field>
<field name="name">Supplier</field>
diff -r e6dfc508d927 trytond/trytond/modules/stock_lot/view/lot_by_location_start_form.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trytond/trytond/modules/stock_lot/view/lot_by_location_start_form.xml Thu Dec 15 23:48:12 2016 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<form string="Lot by Location">
+ <label name="forecast_date"/>
+ <field name="forecast_date"/>
+</form>
diff -r 7ccc2bda2cda trytond/trytond/modules/stock_lot/locale/ca_ES.po
--- a/trytond/trytond/modules/stock_lot/locale/ca_ES.po Sat Dec 17 18:03:06 2016 +0100
+++ b/trytond/trytond/modules/stock_lot/locale/ca_ES.po Wed Jan 25 11:07:06 2017 +0100
@@ -86,6 +86,14 @@
msgid "Write User"
msgstr "Usuari modificació"
+msgctxt "field:stock.lot.by_location.start,forecast_date:"
+msgid "At Date"
+msgstr "A data"
+
+msgctxt "field:stock.lot.by_location.start,id:"
+msgid "ID"
+msgstr "ID"
+
msgctxt "field:stock.lot.type,code:"
msgid "Code"
msgstr "Codi"
@@ -174,6 +182,16 @@
msgid "The type of location for which lot is required"
msgstr "Tipus d'ubicació per la qual el lot és obligatori."
+msgctxt "help:stock.lot.by_location.start,forecast_date:"
+msgid ""
+"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."
+msgstr ""
+"Permet calcular les quantitats previstes d'estoc per a aquesta data.\n"
+"* Un valor buit és un data infinita en el futur.\n"
+"* Una data en el passat proporcionarà valors històrics."
+
msgctxt "model:ir.action,name:act_lot_form"
msgid "Lots"
msgstr "Lots"
@@ -182,6 +200,10 @@
msgid "Moves"
msgstr "Moviments"
+msgctxt "model:ir.action,name:wizard_lot_by_location"
+msgid "Lot by Locations"
+msgstr "Lot per ubicacions"
+
msgctxt "model:ir.ui.menu,name:menu_lot_form"
msgid "Lots"
msgstr "Lots"
@@ -194,6 +216,10 @@
msgid "Stock Lot"
msgstr "Lot"
+msgctxt "model:stock.lot.by_location.start,name:"
+msgid "Lot by Location"
+msgstr "Lot per ubicació"
+
msgctxt "model:stock.lot.type,name:"
msgid "Stock Lot Type"
msgstr "Tipus de lot"
@@ -226,6 +252,10 @@
msgid "Lots"
msgstr "Lots"
+msgctxt "view:stock.lot.by_location.start:"
+msgid "Lot by Location"
+msgstr "Lot per ubicació"
+
msgctxt "view:stock.lot:"
msgid "Lot"
msgstr "Lot"
@@ -241,3 +271,11 @@
msgctxt "view:stock.period.cache.lot:"
msgid "Period Lot Caches"
msgstr "Períodes d'estoc precalculat "
+
+msgctxt "wizard_button:stock.lot.by_location,start,end:"
+msgid "Cancel"
+msgstr "Cancel·la"
+
+msgctxt "wizard_button:stock.lot.by_location,start,open:"
+msgid "Open"
+msgstr "Obre"
diff -r 7ccc2bda2cda trytond/trytond/modules/stock_lot/locale/es_ES.po
--- a/trytond/trytond/modules/stock_lot/locale/es_ES.po Sat Dec 17 18:03:06 2016 +0100
+++ b/trytond/trytond/modules/stock_lot/locale/es_ES.po Wed Jan 25 11:07:06 2017 +0100
@@ -86,6 +86,14 @@
msgid "Write User"
msgstr "Usuario modificación"
+msgctxt "field:stock.lot.by_location.start,forecast_date:"
+msgid "At Date"
+msgstr "A fecha"
+
+msgctxt "field:stock.lot.by_location.start,id:"
+msgid "ID"
+msgstr "ID"
+
msgctxt "field:stock.lot.type,code:"
msgid "Code"
msgstr "Código"
@@ -174,6 +182,16 @@
msgid "The type of location for which lot is required"
msgstr "El tipo de ubicación en la que el lote es obligatorio."
+msgctxt "help:stock.lot.by_location.start,forecast_date:"
+msgid ""
+"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."
+msgstr ""
+"Permite calcular las cantidades previstas de stock para esta fecha.\n"
+"* Un valor vacío es un fecha infinita en el futuro.\n"
+"* Una fecha en el pasado proporcionará valores históricos."
+
msgctxt "model:ir.action,name:act_lot_form"
msgid "Lots"
msgstr "Lotes"
@@ -182,6 +200,10 @@
msgid "Moves"
msgstr "Movimientos"
+msgctxt "model:ir.action,name:wizard_lot_by_location"
+msgid "Lot by Locations"
+msgstr "Lote por ubicaciones"
+
msgctxt "model:ir.ui.menu,name:menu_lot_form"
msgid "Lots"
msgstr "Lotes"
@@ -194,6 +216,10 @@
msgid "Stock Lot"
msgstr "Lote stock"
+msgctxt "model:stock.lot.by_location.start,name:"
+msgid "Lot by Location"
+msgstr "Lote por ubicación"
+
msgctxt "model:stock.lot.type,name:"
msgid "Stock Lot Type"
msgstr "Tipo lote stock"
@@ -226,6 +252,10 @@
msgid "Lots"
msgstr "Lotes"
+msgctxt "view:stock.lot.by_location.start:"
+msgid "Lot by Location"
+msgstr "Lote por ubicación"
+
msgctxt "view:stock.lot:"
msgid "Lot"
msgstr "Lote"
@@ -241,3 +271,11 @@
msgctxt "view:stock.period.cache.lot:"
msgid "Period Lot Caches"
msgstr "Período lote precalculados"
+
+msgctxt "wizard_button:stock.lot.by_location,start,end:"
+msgid "Cancel"
+msgstr "Cancelar"
+
+msgctxt "wizard_button:stock.lot.by_location,start,open:"
+msgid "Open"
+msgstr "Abrir"