issue239_630.diff # [stock] get location quantity by product, product template or lot

This commit is contained in:
Raimon Esteve 2019-04-10 17:47:05 +02:00
parent 9c9ed16adc
commit 79ad25915c
3 changed files with 38 additions and 328 deletions

29
issue239_630.diff Normal file
View File

@ -0,0 +1,29 @@
diff -r 366b4e8da556 trytond/trytond/modules/stock/location.py
--- a/trytond/trytond/modules/stock/location.py Wed Apr 10 14:21:58 2019 +0200
+++ b/trytond/trytond/modules/stock/location.py Wed Apr 10 17:42:42 2019 +0200
@@ -355,11 +355,14 @@
if trans_context.get('product') is not None:
grouping = ('product',)
grouping_filter = ([trans_context['product']],)
- key = trans_context['product']
+ key = (trans_context['product'],)
+ if trans_context.get('lot') is not None:
+ grouping += ('lot', )
+ key += (trans_context['lot'],)
else:
grouping = ('product.template',)
grouping_filter = ([trans_context['product_template']],)
- key = trans_context['product_template']
+ key = (trans_context['product_template'],)
pbl = {}
for sub_locations in grouped_slice(locations):
location_ids = [l.id for l in sub_locations]
@@ -370,7 +373,7 @@
grouping_filter=grouping_filter,
with_childs=trans_context.get('with_childs', True)))
- return dict((loc.id, pbl.get((loc.id, key), 0)) for loc in locations)
+ return dict((loc.id, pbl.get((loc.id,) + key, 0)) for loc in locations)
@classmethod
def search_quantity(cls, name, domain):

View File

@ -1,323 +0,0 @@
diff -r d1102046dce6 __init__.py
--- a/trytond/trytond/modules/stock_lot/__init__.py Mon Apr 23 17:32:23 2018 +0200
+++ b/trytond/trytond/modules/stock_lot/__init__.py Thu Jun 14 14:59:26 2018 +0200
@@ -2,24 +2,29 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
-from .stock import *
-from .product import *
+from . import stock
+from . import product
def register():
Pool.register(
- Lot,
- LotByLocationContext,
- LotType,
- Move,
- ShipmentIn,
- ShipmentOut,
- ShipmentOutReturn,
- Period,
- PeriodCacheLot,
- Inventory,
- InventoryLine,
- Template,
- Product,
- TemplateLotType,
+ stock.Lot,
+ stock.LotByLocationContext,
+ stock.LotType,
+ stock.Move,
+ stock.ShipmentIn,
+ stock.ShipmentOut,
+ stock.ShipmentOutReturn,
+ stock.Period,
+ stock.PeriodCacheLot,
+ stock.Inventory,
+ stock.InventoryLine,
+ product.Template,
+ product.Product,
+ product.TemplateLotType,
+ stock.Location,
+ stock.LotByLocationStart,
module='stock_lot', type_='model')
+ Pool.register(
+ stock.LotByLocation,
+ module='stock_lot', type_='wizard')
diff -r d1102046dce6 stock.py
--- a/trytond/trytond/modules/stock_lot/stock.py Mon Apr 23 17:32:23 2018 +0200
+++ b/trytond/trytond/modules/stock_lot/stock.py Thu Jun 14 14:59:26 2018 +0200
@@ -4,16 +4,86 @@
from collections import defaultdict
from trytond.model import ModelView, ModelSQL, 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.modules.stock import StockMixin
+from trytond.wizard import Wizard, StateView, StateAction, Button
-__all__ = ['Lot', 'LotType', 'Move', 'ShipmentIn', 'ShipmentOut',
+_all__ = ['Lot', 'LotType', 'Move', 'ShipmentIn', 'ShipmentOut',
'LotByLocationContext', 'ShipmentOutReturn',
'Period', 'PeriodCacheLot',
- 'Inventory', 'InventoryLine', 'LotByLocationContext']
+ 'Inventory', 'InventoryLine', 'LotByLocationContext',
+ 'Location', 'LotByLocation', 'LotByLocationStart']
+
+
+class Location:
+ __name__ = 'stock.location'
+ __metaclass__ = PoolMeta
+
+ @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'])
+ action['name'] += ' - %s (%s) @ %s' % (lot.rec_name,
+ lot.product.default_uom.rec_name, date)
+ return action, {}
class Lot(ModelSQL, ModelView, StockMixin):
"Stock Lot"
diff -r d1102046dce6 stock.xml
--- a/trytond/trytond/modules/stock_lot/stock.xml Mon Apr 23 17:32:23 2018 +0200
+++ b/trytond/trytond/modules/stock_lot/stock.xml Thu Jun 14 14:59:26 2018 +0200
@@ -112,6 +112,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 d1102046dce6 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 Jun 14 14:59:26 2018 +0200
@@ -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>
+ <label name="forecast_date"/>
+ <field name="forecast_date"/>
+</form>
diff -r d1102046dce6 locale/ca.po
--- a/trytond/trytond/modules/stock_lot/locale/ca.po Mon Apr 23 17:32:23 2018 +0200
+++ b/trytond/trytond/modules/stock_lot/locale/ca.po Wed Jun 27 12:46:43 2018 +0200
@@ -90,6 +90,14 @@
msgid "Write User"
msgstr "Usuari de 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"
@@ -194,6 +202,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 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 "help:stock.lots_by_location.context,forecast_date:"
msgid ""
"Allow to compute expected stock quantities for this date.\n"
@@ -216,6 +234,10 @@
msgid "Moves"
msgstr "Moviments"
+msgctxt "model:ir.action,name:wizard_lot_by_location"
+msgid "Lot by Locations"
+msgstr "Lot per ubicació"
+
msgctxt "model:ir.ui.menu,name:menu_lot_form"
msgid "Lots"
msgstr "Lots"
@@ -228,6 +250,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"
@@ -279,3 +305,11 @@
msgctxt "view:stock.period.cache.lot:"
msgid "Period Lot Caches"
msgstr "Períodes d'existències 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 "Pendent"
diff -r d1102046dce6 locale/es.po
--- a/trytond/trytond/modules/stock_lot/locale/es.po Mon Apr 23 17:32:23 2018 +0200
+++ b/trytond/trytond/modules/stock_lot/locale/es.po Wed Jun 27 12:46:43 2018 +0200
@@ -90,6 +90,14 @@
msgid "Write User"
msgstr "Usuario de modificación"
+msgctxt "field:stock.lot.by_location.start,forecast_date:"
+msgid "At Date"
+msgstr "A la fecha"
+
+msgctxt "field:stock.lot.by_location.start,id:"
+msgid "ID"
+msgstr "ID"
+
msgctxt "field:stock.lot.type,code:"
msgid "Code"
msgstr "Código"
@@ -194,6 +202,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 para esta fecha.\n"
+"* Un valor vacío es una fecha infinita en el futuro.\n"
+"* Una fecha en el pasado proporcionará valores históricos. "
+
msgctxt "help:stock.lots_by_location.context,forecast_date:"
msgid ""
"Allow to compute expected stock quantities for this date.\n"
@@ -216,6 +234,10 @@
msgid "Moves"
msgstr "Movimientos"
+msgctxt "model:ir.action,name:wizard_lot_by_location"
+msgid "Lot by Locations"
+msgstr "Lotes por ubicaciones"
+
msgctxt "model:ir.ui.menu,name:menu_lot_form"
msgid "Lots"
msgstr "Lotes"
@@ -228,6 +250,10 @@
msgid "Stock Lot"
msgstr "Lote"
+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"
@@ -279,3 +305,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 "Pendiente"

14
series
View File

@ -1,21 +1,25 @@
babi_multiprocess.diff # [trytond] babi multiprocess
trytond_test_database.diff # [trytond] avoid errors on upgrades from version 3.4
party_identifier_migration.diff # [Party] avoid errors on upgrades
logging_jsonrpc_exeption.diff # [trytond] logging JSONRPC Exception
issue3932.diff # [account] rule account move and account move line by company
issue6253.diff # [account_invoice] add invoice type criteria
issue4506.diff # [account_invoice] Add credit invoices keyword from account.invoice
issue4030.diff # [analytic_account] Not selected root accounts in analytic account lines
sale_list_price.diff # [sale] Can't convert to currency with list price is null (multicompany)
lock_stock_move.diff # [stock] Function to overwrite if lock table or not
issue4482.diff # [stock] stock inventory misses company access rule
search_warehouse.diff #[stock] search function for warehouse.
issue10467.diff # stock_lot: add lot to grouping if lot it's required on product
search_warehouse.diff # [stock] search function for warehouse
issue239_630.diff # [stock] get location quantity by product, product template or lot
issue53451002_1_10001.diff # [stock] Allow configuring which quantity is grouped in compute_quantities_query() needed by stock_number_of_packages
stock_lot_sled.diff # [stock_lot_sled] Allow configuring which quantity is grouped in compute_quantities_query() needed by stock_number_of_packages
sale_list_price.diff # [sale] Can't convert to currency with list price is null (multicompany)
issue10467.diff # [stock_lot] add lot to grouping when assign try if lot it's required on product
party_identifier_migration.diff # [Party] avoid errors on upgrades
#issue240_631.diff # [stock_lot] stock_by_locations get all locations with that lot. #TODO fer mòdul
# TODO: improve_performance_on_try_assign.diff # [stock] change browse of product to get default_uom to pysql