Add issue7805.diff and add missing ".diff" suffix to issue8752

This commit is contained in:
Albert Cervera i Areny 2019-12-07 01:18:44 +01:00
parent eb800a541d
commit 683242faa7
2 changed files with 109 additions and 1 deletions

106
issue7805.diff Normal file
View File

@ -0,0 +1,106 @@
diff -r b56a5b6d059d trytond/trytond/modules/stock/move.py
--- a/trytond/trytond/modules/stock/move.py Wed Oct 23 10:24:05 2019 +0200
+++ b/trytond/trytond/modules/stock/move.py Wed Oct 23 10:35:18 2019 +0200
@@ -912,7 +912,8 @@
@classmethod
def compute_quantities_query(cls, location_ids, with_childs=False,
- grouping=('product',), grouping_filter=None):
+ grouping=('product',), grouping_filter=None,
+ quantity_field='internal_quantity'):
"""
Prepare a query object to compute for each location and product the
stock quantity in the default uom of the product.
@@ -930,6 +931,8 @@
stock_skip_warehouse: if set, quantities on a warehouse are no more
quantities of all child locations but quantities of the storage
zone.
+ quantity_field is the name of the field containing the quantity to
+ be aggregated.
If with_childs, it computes also for child locations.
grouping is a tuple of Move (or Product if prefixed by 'product.')
field names and defines how stock moves are grouped.
@@ -982,7 +985,7 @@
if use_product:
product = Product.__table__()
columns = ['id', 'state', 'effective_date', 'planned_date',
- 'internal_quantity', 'from_location', 'to_location', 'company']
+ quantity_field, 'from_location', 'to_location', 'company']
columns += [c for c in grouping if c not in columns]
columns = [get_column(c, move, product) for c in columns]
move = (move
@@ -996,7 +999,7 @@
period_table = Period.__table__()
if use_product:
product_cache = Product.__table__()
- columns = ['internal_quantity', 'period', 'location']
+ columns = [quantity_field, 'period', 'location']
columns += [c for c in grouping if c not in columns]
columns = [get_column(c, period_cache, product_cache)
for c in columns]
@@ -1017,7 +1020,7 @@
to_location = Location.__table__()
to_parent_location = Location.__table__()
columns = ['id', 'state', 'effective_date', 'planned_date',
- 'internal_quantity', 'company']
+ quantity_field, 'company']
columns += [c for c in grouping if c not in columns]
columns = [Column(move, c).as_(c) for c in columns]
@@ -1072,7 +1075,7 @@
if PeriodCache:
location = Location.__table__()
parent_location = Location.__table__()
- columns = ['internal_quantity', 'period'] + list(grouping)
+ columns = [quantity_field, 'period'] + list(grouping)
columns = [Column(period_cache, c).as_(c) for c in columns]
period_cache = Union(
period_cache.select(
@@ -1270,7 +1273,7 @@
move_keys_alias = [Column(move, key).as_(key) for key in grouping]
move_keys = [Column(move, key) for key in grouping]
query = move.select(move.to_location.as_('location'),
- Sum(move.internal_quantity).as_('quantity'),
+ Sum(getattr(move, quantity_field)).as_('quantity'),
*move_keys_alias,
where=state_date_clause_in
& where
@@ -1283,7 +1286,7 @@
& dest_clause_from,
group_by=[move.to_location] + move_keys)
query = Union(query, move.select(move.from_location.as_('location'),
- (-Sum(move.internal_quantity)).as_('quantity'),
+ (-Sum(getattr(move, quantity_field))).as_('quantity'),
*move_keys_alias,
where=state_date_clause_out
& where
@@ -1297,7 +1300,7 @@
for key in grouping]
query = Union(query, from_period.select(
period_cache.location.as_('location'),
- period_cache.internal_quantity.as_('quantity'),
+ getattr(period_cache, quantity_field).as_('quantity'),
*period_keys,
where=(period_cache.period
== (period.id if period else None))
--- a/trytond/trytond/modules/stock_lot_sled/stock.py Wed May 01 18:05:26 2019 +0200
+++ b/trytond/trytond/modules/stock_lot_sled/stock.py Mon May 06 23:42:38 2019 +0200
@@ -221,7 +221,8 @@
@classmethod
def compute_quantities_query(cls, location_ids, with_childs=False,
- grouping=('product',), grouping_filter=None):
+ grouping=('product',), grouping_filter=None,
+ quantity_field='internal_quantity'):
pool = Pool()
Date = pool.get('ir.date')
Lot = pool.get('stock.lot')
@@ -229,7 +230,7 @@
query = super(Move, cls).compute_quantities_query(
location_ids, with_childs=with_childs, grouping=grouping,
- grouping_filter=grouping_filter)
+ grouping_filter=grouping_filter, quantity_field=quantity_field)
context = Transaction().context
today = Date.today()

4
series
View File

@ -32,7 +32,9 @@ production_view.diff #[production] Split inputs and outputs on pages
issue8702.diff # [stock_supply_forecast] Support production forecast
sale_allow_group_shipments_with_different_dates.diff # [sale_shipment_grouping] Deletes the grouping condition by dates
party_identifier_migration.diff # set vat_eu as valid vat
issue8752 # [analytic_invoice]
issue8752.diff # [analytic_invoice]
issue7805.diff # [stock] [stock_lot_sled] Allow configuring which quantity is grouped in compute_quantities_query()
#improve_performance_on_try_assign.diff # [stock] change browse of product to get default_uom to pysql
#issue53451002_1_10001.diff # [stock] Allow configuring which quantity is grouped in compute_quantities_query() needed by stock_number_of_packages Issue7805 (only needed by stock_number_of_packages)