trytond-patches/issue240_631.diff

335 lines
10 KiB
Diff

Index: __init__.py
===================================================================
--- .a/trytond/trytond/modules/stock_lot/__init__.py
+++ .b/trytond/trytond/modules/stock_lot/__init__.py
@@ -21,4 +21,9 @@
Template,
Product,
TemplateLotType,
+ Location,
+ LotByLocationStart,
module='stock_lot', type_='model')
+ Pool.register(
+ LotByLocation,
+ module='stock_lot', type_='wizard')
Index: stock.py
===================================================================
--- .a/trytond/trytond/modules/stock_lot/stock.py
+++ .b/trytond/trytond/modules/stock_lot/stock.py
@@ -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, Workflow, fields
-from trytond.pyson import Eval
+from trytond.pyson import PYSONEncoder, Eval
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', 'LotByLocation', 'LotByLocationStart']
__metaclass__ = PoolMeta
@@ -294,3 +297,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, {}
Index: stock.xml
===================================================================
--- .a/trytond/trytond/modules/stock_lot/stock.xml
+++ .b/trytond/trytond/modules/stock_lot/stock.xml
@@ -48,6 +48,28 @@
<field name="perm_delete" eval="True"/>
</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>
Index: view/lot_by_location_start_form.xml
===================================================================
new file mode 100644
--- /dev/null
+++ .b/trytond/trytond/modules/stock_lot/view/lot_by_location_start_form.xml
@@ -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>
Index: locale/ca_ES.po
===================================================================
--- .a/trytond/trytond/modules/stock_lot/locale/ca_ES.po
+++ .b/trytond/trytond/modules/stock_lot/locale/ca_ES.po
@@ -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 "Identificador"
+
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 "Lots per ubicació"
+
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"
@@ -230,6 +256,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"
@@ -245,3 +275,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"
Index: locale/es_ES.po
===================================================================
--- .a/trytond/trytond/modules/stock_lot/locale/es_ES.po
+++ .b/trytond/trytond/modules/stock_lot/locale/es_ES.po
@@ -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 "Identificador"
+
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 por cada lote es requerido."
+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 "Lotes por ubicación"
+
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"
@@ -230,6 +256,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"
@@ -245,3 +275,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 "Cancel·lar"
+
+msgctxt "wizard_button:stock.lot.by_location,start,open:"
+msgid "Open"
+msgstr "Abrir"