issue8394 stock_lot_sled append condition in sub_query when has a condition

This commit is contained in:
Raimon Esteve 2019-06-06 00:23:46 +02:00
parent d8504569fb
commit 11f24315a3
2 changed files with 36 additions and 0 deletions

35
issue8394.diff Normal file
View File

@ -0,0 +1,35 @@
diff -r c845701bdb19 trytond/trytond/modules/stock_lot_sled/stock.py
--- a/trytond/trytond/modules/stock_lot_sled/stock.py Thu Jun 06 00:13:21 2019 +0200
+++ b/trytond/trytond/modules/stock_lot_sled/stock.py Thu Jun 06 00:22:10 2019 +0200
@@ -299,9 +299,13 @@
for sub_query in find_queries(union):
lot = Lot.__table__()
if add_join(sub_query.from_, lot):
- sub_query.where &= (
+ sub_where = (
(lot.shelf_life_expiration_date == Null)
| (lot.shelf_life_expiration_date >= expiration_date))
+ if sub_query.where:
+ sub_query.where &= sub_where
+ else:
+ sub_query.where = sub_where
stock_date_start = context.get('stock_date_start')
if stock_date_start:
@@ -316,11 +320,15 @@
lot = Lot.__table__()
if add_join(sub_query.from_, lot):
# only lot expiring during the period
- sub_query.where &= (
+ sub_where = (
(lot.shelf_life_expiration_date >=
stock_date_start)
& (lot.shelf_life_expiration_date <
stock_date_end))
+ if sub_query.where:
+ sub_query.where &= sub_where
+ else:
+ sub_query.where = sub_where
# Inverse quantity
for column in sub_query._columns:
if (isinstance(column, As)

1
series
View File

@ -19,6 +19,7 @@ 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
issue8394.diff # [stock_lot_sled] Allow configuring which quantity is grouped in compute_quantities_query() needed by stock_number_of_packages
issue10467.diff # [stock_lot] add lot to grouping when assign try if lot it's required on product