Tryton - Issues

 

Issue8394

Title Unsupported operand type(s) for &=: 'NoneType' and 'Or'
Priority bug Status resolved
Superseder Nosy List ced, resteve, reviewbot, roundup-bot
Type crash Components stock_lot_sled
Assigned To ced Keywords review
Reviews 253951002
View: 253951002

Created on 2019-06-04.13:12:31 by resteve, last changed by roundup-bot.

Messages
New changeset d8d738921658 by Cédric Krier in branch 'default':
Make compute_quantities_query works with product.template grouping
https://hg.tryton.org/tryton-env/rev/d8d738921658
New changeset d485a874551d by Cédric Krier in branch 'default':
Make compute_quantities_query works with product.template grouping
https://hg.tryton.org/modules/stock_lot_sled/rev/d485a874551d
review253951002 updated at https://codereview.tryton.org/253951002/#ps267731002
msg50936 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-07-27.19:48:11
Writting test shows that there are more issue. Here is review253951002 which fix the case of grouping by product.template.
review269611002 updated at https://codereview.tryton.org/269611002/#ps265531002
review269611002 updated at https://codereview.tryton.org/269611002/#ps285261002
msg49969 (view) Author: [hidden] (resteve) Date: 2019-06-04.13:32:17
review269611002
msg49968 (view) Author: [hidden] (resteve) Date: 2019-06-04.13:12:29
1. Install stock_lot_sled module
2- Go a product and click to "Locations List Quantity" (act_location_quantity_list). I get the traceback [1]

Debug:

1- the query is [2]
2- I detected not all "sub_query" in "find_queries(union)" are "where" and crash. Example that not has a "where":

(('SELECT "a"."internal_quantity" AS "internal_quantity", "a"."period" AS "period", "a"."location" AS "location", "b"."template" AS "product.template" FROM "stock_period_cache" AS "a" INNER JOIN "product_product" AS "b" ON ("a"."product" = "b"."id")', ()), None)


[1] 

ERROR:tryton.common.common:Traceback (most recent call last):
  File "/trytond/wsgi.py", line 104, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 48, in rpc
    request, database_name, *request.rpc_params)
  File "/site-packages/wrapt/wrappers.py", line 564, in __call__
    args, kwargs)
  File "/trytond/wsgi.py", line 72, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 197, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/modelsql.py", line 1243, in search
    tables, expression = cls.search_domain(domain)
  File "/trytond/model/modelsql.py", line 1427, in search_domain
    expression = convert(domain)
  File "/trytond/model/modelsql.py", line 1425, in convert
    domain[1:] if domain[0] == 'AND' else domain)))
  File "/trytond/model/modelsql.py", line 1424, in <genexpr>
    return And((convert(d) for d in (
  File "/trytond/model/modelsql.py", line 1415, in convert
    expression = field.convert_domain(domain, tables, cls)
  File "/trytond/model/fields/function.py", line 79, in convert_domain
    return getattr(Model, self.searcher)(self.name, domain)
  File "/trytond/modules/stock/location.py", line 394, in search_quantity
    if operator_(getattr(location, name), operand):
  File "/trytond/model/fields/field.py", line 332, in __get__
    return inst.__getattr__(self.name)
  File "/trytond/model/modelstorage.py", line 1525, in __getattr__
    read_data = self.read(list(ids), list(ffields.keys()))
  File "/trytond/model/modelsql.py", line 832, in read
    getter_results = field.get(ids, cls, field_list, values=result)
  File "/trytond/model/fields/function.py", line 106, in get
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/function.py", line 106, in <genexpr>
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/function.py", line 99, in call
    return method(records, name)
  File "/trytond/modules/stock/location.py", line 374, in get_quantity
    with_childs=trans_context.get('with_childs', True)))
  File "/trytond/modules/stock/product.py", line 199, in products_by_location
    grouping=grouping, grouping_filter=grouping_filter)
  File "/trytond/modules/stock_number_of_packages/move.py", line 128, in compute_quantities_query
    grouping_filter=grouping_filter, quantity_field=quantity_field)
  File "/trytond/modules/stock_lot_sled/stock.py", line 304, in compute_quantities_query
    | (lot.shelf_life_expiration_date >= expiration_date))
TypeError: unsupported operand type(s) for &=: 'NoneType' and 'Or'

Fault: unsupported operand type(s) for &=: 'NoneType' and 'Or'

[2] 
('SELECT "a"."to_location" AS "location", SUM("a"."internal_quantity") AS "quantity", "a"."product.template" AS "product.template" FROM (SELECT "b"."id" AS "id", "b"."state" AS "state", "b"."effective_date" AS "effective_date", "b"."planned_date" AS "planned_date", "b"."internal_quantity" AS "internal_quantity", "b"."from_location" AS "from_location", "b"."to_location" AS "to_location", "d"."template" AS "product.template" FROM "stock_move" AS "b" LEFT JOIN "stock_lot" AS "c" ON ("b"."lot" = "c"."id") INNER JOIN "product_product" AS "d" ON ("b"."product" = "d"."id")) AS "a" WHERE ((((((((("a"."state" IN (%s, %s)) AND (((("a"."effective_date" IS NULL) AND ("a"."planned_date" <= %s)) OR ("a"."effective_date" <= %s)) OR ("a"."state" = %s))) OR (("a"."state" IN (%s, %s, %s)) AND ((((("a"."effective_date" IS NULL) AND (COALESCE("a"."planned_date", %s) <= %s)) AND (COALESCE("a"."planned_date", %s) >= %s)) OR (("a"."effective_date" <= %s) AND ("a"."effective_date" >= %s))) OR ("a"."state" = %s)))) AND (COALESCE("a"."effective_date", "a"."planned_date", %s) > %s)) AND %s AND (("a"."product.template" IN (%s)))) AND ("a"."to_location" IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s))) AND ("a"."id" IN (SELECT "e"."id" AS "id" FROM "stock_move" AS "e" WHERE (((("e"."company" = %s))))))) AND %s) AND (("f"."shelf_life_expiration_date" IS NULL) OR ("f"."shelf_life_expiration_date" >= %s))) GROUP BY "a"."to_location", "a"."product.template" UNION ALL SELECT "a"."from_location" AS "location", (- SUM("a"."internal_quantity")) AS "quantity", "a"."product.template" AS "product.template" FROM (SELECT "b"."id" AS "id", "b"."state" AS "state", "b"."effective_date" AS "effective_date", "b"."planned_date" AS "planned_date", "b"."internal_quantity" AS "internal_quantity", "b"."from_location" AS "from_location", "b"."to_location" AS "to_location", "d"."template" AS "product.template" FROM "stock_move" AS "b" LEFT JOIN "stock_lot" AS "c" ON ("b"."lot" = "c"."id") INNER JOIN "product_product" AS "d" ON ("b"."product" = "d"."id")) AS "a" WHERE (((((((("a"."state" IN (%s, %s)) AND (((("a"."effective_date" IS NULL) AND ("a"."planned_date" <= %s)) OR ("a"."effective_date" <= %s)) OR ("a"."state" = %s))) OR (("a"."state" IN (%s, %s, %s)) AND ((((("a"."effective_date" IS NULL) AND (COALESCE("a"."planned_date", %s) <= %s)) AND (COALESCE("a"."planned_date", %s) >= %s)) OR (("a"."effective_date" <= %s) AND ("a"."effective_date" >= %s))) OR ("a"."state" = %s)))) AND (COALESCE("a"."effective_date", "a"."planned_date", %s) > %s)) AND %s AND (("a"."product.template" IN (%s)))) AND ("a"."from_location" IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s))) AND ("a"."id" IN (SELECT "e"."id" AS "id" FROM "stock_move" AS "e" WHERE (((("e"."company" = %s))))))) AND %s) GROUP BY "a"."from_location", "a"."product.template" UNION ALL SELECT "g"."location" AS "location", "g"."internal_quantity" AS "quantity", "g"."product.template" AS "product.template" FROM (SELECT "h"."internal_quantity" AS "internal_quantity", "h"."period" AS "period", "h"."location" AS "location", "i"."template" AS "product.template" FROM "stock_period_cache" AS "h" INNER JOIN "product_product" AS "i" ON ("h"."product" = "i"."id")) AS "g" WHERE (((("g"."period" = %s) AND %s AND (("g"."product.template" IN (%s)))) AND ("g"."location" IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s))) AND %s)', ('done', 'done', datetime.date(2019, 6, 4), datetime.date(2019, 6, 4), 'assigned', 'done', 'assigned', 'draft', datetime.date(9999, 12, 31), datetime.date(2019, 6, 4), datetime.date(9999, 12, 31), datetime.date(2019, 6, 4), datetime.date(2019, 6, 4), datetime.date(2019, 6, 4), 'assigned', datetime.date(9999, 12, 31), datetime.date(2019, 4, 1), True, 1442, 6, 43, 78, 39, 24, 9, 14, 29, 34, 86, 82, 20, 90, 11, 13, 101, 98, 100, 99, 38, 19, 33, 28, 80, 41, 26, 22, 31, 36, 88, 84, 92, 81, 53, 50, 52, 51, 61, 58, 60, 59, 97, 95, 94, 96, 72, 69, 71, 70, 64, 66, 67, 65, 57, 54, 56, 55, 89, 85, 77, 74, 76, 75, 48, 44, 46, 45, 93, 7, 8, 42, 27, 32, 12, 37, 23, 5, 79, 40, 25, 10, 30, 35, 87, 83, 21, 91, 68, 63, 103, 78, True, datetime.date(2019, 6, 4), 'done', 'done', datetime.date(2019, 6, 4), datetime.date(2019, 6, 4), 'assigned', 'done', 'assigned', 'draft', datetime.date(9999, 12, 31), datetime.date(2019, 6, 4), datetime.date(9999, 12, 31), datetime.date(2019, 6, 4), datetime.date(2019, 6, 4), datetime.date(2019, 6, 4), 'assigned', datetime.date(9999, 12, 31), datetime.date(2019, 4, 1), True, 1442, 6, 43, 78, 39, 24, 9, 14, 29, 34, 86, 82, 20, 90, 11, 13, 101, 98, 100, 99, 38, 19, 33, 28, 80, 41, 26, 22, 31, 36, 88, 84, 92, 81, 53, 50, 52, 51, 61, 58, 60, 59, 97, 95, 94, 96, 72, 69, 71, 70, 64, 66, 67, 65, 57, 54, 56, 55, 89, 85, 77, 74, 76, 75, 48, 44, 46, 45, 93, 7, 8, 42, 27, 32, 12, 37, 23, 5, 79, 40, 25, 10, 30, 35, 87, 83, 21, 91, 68, 63, 103, 78, True, 34, True, 1442, 6, 43, 78, 39, 24, 9, 14, 29, 34, 86, 82, 20, 90, 11, 13, 101, 98, 100, 99, 38, 19, 33, 28, 80, 41, 26, 22, 31, 36, 88, 84, 92, 81, 53, 50, 52, 51, 61, 58, 60, 59, 97, 95, 94, 96, 72, 69, 71, 70, 64, 66, 67, 65, 57, 54, 56, 55, 89, 85, 77, 74, 76, 75, 48, 44, 46, 45, 93, 7, 8, 42, 27, 32, 12, 37, 23, 5, 79, 40, 25, 10, 30, 35, 87, 83, 21, 91, 68, 63, 103, True))
History
Date User Action Args
2019-08-07 19:25:21roundup-botsetmessages: + msg51094
2019-08-07 19:25:16roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg51093
2019-07-27 19:56:24reviewbotsetmessages: + msg50937
2019-07-27 19:48:11cedsetstatus: in-progress -> testing
reviews: 269611002 -> 253951002
messages: + msg50936
2019-07-27 19:40:15cedsetstatus: chatting -> in-progress
assignedto: resteve -> ced
type: crash
nosy: + ced
2019-06-06 00:42:13reviewbotsetmessages: + msg50102
2019-06-05 10:34:50jansetassignedto: resteve
2019-06-04 13:35:30reviewbotsetnosy: + reviewbot
messages: + msg49970
2019-06-04 13:32:17restevesetreviews: 269611002
messages: + msg49969
keyword: + review
2019-06-04 13:12:31restevecreate