changeset ef20d6d41683 in modules/stock:6.0 details: https://hg.tryton.org/modules/stock?cmd=changeset&node=ef20d6d41683 description: Use unique ID for today record in ProductQuantitiesByWarehouse query
We must use a unique ID to ensure to not collide with records in the transaction cache. issue10831 review353021002 (grafted from a1917dccb59b826c803cdc58d939aea334695705) diffstat: product.py | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diffs (49 lines): diff -r 42975b4ee4cc -r ef20d6d41683 product.py --- a/product.py Thu Sep 16 23:47:02 2021 +0200 +++ b/product.py Fri Oct 15 19:16:47 2021 +0200 @@ -552,7 +552,7 @@ from_ = move.join(product, condition=move.product == product.id) product_clause = product.template.in_(product_template or [-1]) product_column = Concat('product.template,', product.template) - products = ['product.template,%s' % i for i in product_template] + products = [('product.template', i) for i in product_template] else: product = context.get('product', -1) if product is None: @@ -561,7 +561,7 @@ product = [product] product_clause = move.product.in_(product or [-1]) product_column = Concat('product.product,', move.product) - products = ['product.product,%s' % i for i in product] + products = [('product.product', i) for i in product] if 'warehouse' in context: warehouse = Location(context.get('warehouse')) @@ -576,7 +576,7 @@ ], query=True, order=[])) date_column = Coalesce(move.effective_date, move.planned_date) query = (from_.select( - (Max(move.id) + len(products)).as_('id'), + Max(move.id * 3).as_('id'), Literal(0).as_('create_uid'), CurrentTimestamp().as_('create_date'), Literal(None).as_('write_uid'), @@ -598,14 +598,15 @@ | (date_column >= today)), group_by=(date_column, product_column, move.company), with_=warehouse)) - for i, product in enumerate(products): + for model, id_ in products: + gap = ['product.template', 'product.product'].index(model) + 1 query |= Select([ - Literal(i).as_('id'), + Literal(id_ * 3 + gap).as_('id'), Literal(0).as_('create_uid'), CurrentTimestamp().as_('create_date'), Literal(None).as_('write_uid'), Literal(None).as_('write_date'), - Literal(product).as_('product'), + Literal('%s,%s' % (model, id_)).as_('product'), Literal(today).as_('date'), Literal(context.get('company', -1)).as_('company'), ])