Cannot delete warning from customer shipment when no carrier is defined
Issue is similar as #12861 (closed) To reproduce:
- Activate stock_package_shipping
- Create a sale, process the customer shipment without selecting a carrier.
- When doing pack on the customer shipment a warning is raised because no carrier is selected and then after you get the message "You are not allowed to access "User Warning"."
Full Tracelog:
20506 139639436334784 [2024-03-26 10:44:58,331] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."active" AS "active", "a"."address" AS "address", "a"."allow_pickup" AS "allow_pickup", "a"."code" AS "code", "a"."consignment_party" AS "consignment_party", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."flat_childs" AS "flat_childs", "a"."input_location" AS "input_location", "a"."left" AS "left", "a"."lost_found_location" AS "lost_found_location", "a"."output_location" AS "output_location", "a"."overflowing_location" AS "overflowing_location", "a"."parent" AS "parent", "a"."picking_location" AS "picking_location", "a"."previous_parent" AS "previous_parent", "a"."provisioning_location" AS "provisioning_location", "a"."quarantine_location" AS "quarantine_location", "a"."right" AS "right", "a"."sequence" AS "sequence", "a"."storage_location" AS "storage_location", "a"."supplier_return_location" AS "supplier_return_location", "a"."type" AS "type", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "stock_location" AS "a" LEFT JOIN "party_address" AS "b" ON ("b"."id" = "a"."address") LEFT JOIN (SELECT DISTINCT ON ("d"."res_id", "d"."name") "d"."res_id" AS "res_id", "d"."value" AS "value", "d"."name" AS "name" FROM "ir_translation" AS "d" WHERE ((("d"."lang" = \'en\') AND ("d"."type" = \'model\')) AND ("d"."fuzzy" = false)) ORDER BY "d"."res_id", "d"."name", "d"."id" DESC) AS "c" ON (("c"."res_id" = "a"."id") AND ("c"."name" = \'stock.location,name\')) WHERE (("a"."address" IN (1443)) AND ("a"."active" = true)) ORDER BY "b"."name" ASC, "a"."sequence" ASC NULLS FIRST, COALESCE(NULLIF(COALESCE(NULLIF(NULL, \'\'), "c"."value"), \'\'), "a"."name") ASC, "a"."id" ASC'
20506 139639436334784 [2024-03-26 10:44:58,338] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."always" AS "always", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."name" AS "name", "a"."user" AS "user", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "res_user_warning" AS "a" WHERE ((("a"."user" = 21) AND ("a"."name" = \'shipment_out_no_carrier_stock.shipment.out,1063\')) AND ((("a"."user" = 21)))) ORDER BY "a"."id" ASC'
20506 139639436334784 [2024-03-26 10:44:58,343] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" FROM "ir_rule" AS "a" INNER JOIN "ir_rule_group" AS "b" ON ("b"."id" = "a"."rule_group") INNER JOIN "ir_model" AS "c" ON ("b"."model" = "c"."id") LEFT JOIN "ir_rule_group-res_group" AS "d" ON ("d"."rule_group" = "b"."id") WHERE ((("c"."model" IN (\'res.user.warning\', \'res.user\')) AND ("b"."perm_delete" = true)) AND ((("d"."group" IN (14)) OR ("b"."default_p" = true)) OR ("b"."global_p" = true)))'
20506 139639436334784 [2024-03-26 10:44:58,345] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" FROM "ir_rule_group" AS "a" INNER JOIN "ir_model" AS "b" ON ("a"."model" = "b"."id") LEFT JOIN "ir_rule_group-res_group" AS "c" ON ("c"."rule_group" = "a"."id") WHERE ((("b"."model" IN (\'res.user.warning\', \'res.user\')) AND ("a"."id" NOT IN (SELECT "d"."rule_group" FROM "ir_rule" AS "d"))) AND ("c"."group" IN (14)))'
20506 139639436334784 [2024-03-26 10:44:58,348] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."write_uid" AS "write_uid", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."rule_group" AS "rule_group", "a"."write_date" AS "write_date", "a"."domain" AS "domain" FROM "ir_rule" AS "a" WHERE (("a"."id" IN (1)))'
20506 139639436334784 [2024-03-26 10:44:58,351] DEBUG trytond.backend.postgresql.database b'SELECT "a"."perm_delete" AS "perm_delete", "a"."id" AS "id", "a"."write_uid" AS "write_uid", "a"."create_uid" AS "create_uid", "a"."perm_create" AS "perm_create", "a"."write_date" AS "write_date", "a"."model" AS "model", "a"."global_p" AS "global_p", "a"."perm_read" AS "perm_read", "a"."create_date" AS "create_date", "a"."default_p" AS "default_p", "a"."perm_write" AS "perm_write" FROM "ir_rule_group" AS "a" WHERE (("a"."id" IN (1)))'
20506 139639436334784 [2024-03-26 10:44:58,353] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."write_uid" AS "write_uid", "a"."create_uid" AS "create_uid", "a"."write_date" AS "write_date", "a"."global_search_p" AS "global_search_p", "a"."model" AS "model", "a"."create_date" AS "create_date", "a"."info" AS "info", "a"."module" AS "module" FROM "ir_model" AS "a" WHERE (("a"."id" IN (76)))'
20506 139639436334784 [2024-03-26 10:44:58,355] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" FROM "res_user_warning" AS "a" WHERE ((("a"."id" IN (4037))) AND ((("a"."user" = 21))))'
20506 139639436334784 [2024-03-26 10:44:58,360] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."action" AS "action", "a"."active" AS "active", "a"."condition" AS "condition", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."limit_number" AS "limit_number", "a"."model" AS "model", "a"."notification_email" AS "notification_email", "a"."on_create" AS "on_create", "a"."on_delete" AS "on_delete", "a"."on_time" AS "on_time", "a"."on_write" AS "on_write", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "ir_trigger" AS "a" LEFT JOIN (SELECT DISTINCT ON ("c"."res_id", "c"."name") "c"."res_id" AS "res_id", "c"."value" AS "value", "c"."name" AS "name" FROM "ir_translation" AS "c" WHERE ((("c"."lang" = \'en\') AND ("c"."type" = \'model\')) AND ("c"."fuzzy" = false)) ORDER BY "c"."res_id", "c"."name", "c"."id" DESC) AS "b" ON (("b"."res_id" = "a"."id") AND ("b"."name" = \'ir.trigger,name\')) WHERE (("a"."model" IN (SELECT "d"."id" AS "id" FROM "ir_model" AS "d" WHERE (("d"."model" = \'res.user.warning\')))) AND ("a"."on_delete" = true) AND ("a"."active" = true)) ORDER BY COALESCE(NULLIF(COALESCE(NULLIF(NULL, \'\'), "b"."value"), \'\'), "a"."name") ASC, "a"."id" ASC'
20506 139639436334784 [2024-03-26 10:44:58,362] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."db_id" AS "db_id", "a"."fs_id" AS "fs_id", "a"."fs_values" AS "fs_values", "a"."model" AS "model", "a"."module" AS "module", "a"."noupdate" AS "noupdate", "a"."values" AS "values", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "ir_model_data" AS "a" WHERE (("a"."module" = \'ir\') AND ("a"."fs_id" = \'msg_access_rule_error\')) ORDER BY "a"."id" ASC LIMIT 1'
20506 139639436334784 [2024-03-26 10:44:58,364] DEBUG trytond.backend.postgresql.database b'SELECT "a"."write_date" AS "write_date", "a"."db_id" AS "db_id", "a"."id" AS "id" FROM "ir_model_data" AS "a" WHERE (("a"."id" IN (375)))'
20506 139639436334784 [2024-03-26 10:44:58,365] DEBUG trytond.backend.postgresql.database b'SELECT "a"."write_date" AS "write_date", "a"."text" AS "text", "a"."id" AS "id" FROM "ir_message" AS "a" WHERE (("a"."id" IN (45)))'
20506 139639436334784 [2024-03-26 10:44:58,367] DEBUG trytond.backend.postgresql.database b'SELECT "a"."id" AS "id", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."fuzzy" AS "fuzzy", "a"."lang" AS "lang", "a"."module" AS "module", "a"."name" AS "name", "a"."overriding_module" AS "overriding_module", "a"."res_id" AS "res_id", "a"."src" AS "src", "a"."type" AS "type", "a"."value" AS "value", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "ir_translation" AS "a" WHERE (("a"."lang" = \'en\') AND ("a"."type" = \'model\') AND ("a"."name" = \'ir.message,text\') AND ("a"."value" != \'\') AND ("a"."value" IS NOT NULL) AND ("a"."res_id" IN (45)) AND (("a"."fuzzy" = false) OR ("a"."fuzzy" IS NULL))) ORDER BY "a"."id" ASC'
20506 139639436334784 [2024-03-26 10:44:58,368] INFO trytond.protocols.dispatcher stock.shipment.out.pack([1063], {'client': '43b43b39-995a-4498-9f21-6b411690b661', 'warehouse': 5, 'warehouse.rec_name': 'Callenelle', 'company_filter': 'one', 'employee': 18, 'employee.rec_name': 'Nicolas Roupin', 'company': 1, 'company.rec_name': 'PRECIBALL SA', 'language': 'en', 'language_direction': 'ltr', 'groups': [14], 'roles': [26], 'locale': {'date': '%d/%m/%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': '.', 'mon_grouping': [3, 3, 0], 'mon_decimal_point': ',', 'mon_thousands_sep': '.', 'p_sign_posn': 1, 'n_sign_posn': 1, 'positive_sign': '', 'negative_sign': '-', 'p_cs_precedes': False, 'n_cs_precedes': False, 'p_sep_by_space': True, 'n_sep_by_space': True}, 'label_printer': 4, '_timestamp': {'stock.shipment.out,1063': '1711445630.522659'}}) from negoce@127.0.0.1/tryton_preciball_prod_70_test/ in 4696 ms
Traceback (most recent call last):
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/protocols/dispatcher.py", line 196, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/workflow.py", line 37, in wrapper
result = func(cls, filtered, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/modules/stock_package_shipping/stock.py", line 262, in pack
cls.check_no_carrier(shipments)
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/modules/stock_package_shipping/stock.py", line 222, in check_no_carrier
if Warning.check(name):
^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/res/user.py", line 1097, in check
cls.delete([x for x in warnings if not x.always])
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelsql.py", line 262, in wrapper
return func(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelsql.py", line 1516, in delete
super(ModelSQL, cls).delete(list(sub_records))
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelstorage.py", line 325, in delete
ModelAccess.check(cls.__name__, 'delete')
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/ir/model.py", line 634, in check
raise AccessError(gettext(
trytond.model.modelstorage.AccessError: You are not allowed to access "User Warning". -
20506 139639436334784 [2024-03-26 10:44:58,374] DEBUG trytond.protocols.wrappers <JSONRequest 21@127.0.0.1 'http://localhost:8000/tryton_preciball_prod_70_test/' [POST] model.stock.shipment.out.pack>
Traceback (most recent call last):
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/protocols/wrappers.py", line 197, in wrapper
return func(request, pool, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/protocols/dispatcher.py", line 196, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/workflow.py", line 37, in wrapper
result = func(cls, filtered, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/modules/stock_package_shipping/stock.py", line 262, in pack
cls.check_no_carrier(shipments)
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/modules/stock_package_shipping/stock.py", line 222, in check_no_carrier
if Warning.check(name):
^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/res/user.py", line 1097, in check
cls.delete([x for x in warnings if not x.always])
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelsql.py", line 262, in wrapper
return func(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelsql.py", line 1516, in delete
super(ModelSQL, cls).delete(list(sub_records))
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelstorage.py", line 325, in delete
ModelAccess.check(cls.__name__, 'delete')
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/ir/model.py", line 634, in check
raise AccessError(gettext(
trytond.model.modelstorage.AccessError: You are not allowed to access "User Warning". -
20506 139639436334784 [2024-03-26 10:44:58,375] DEBUG trytond.wsgi Exception when processing <JSONRequest 21@127.0.0.1 'http://localhost:8000/tryton_preciball_prod_70_test/' [POST] model.stock.shipment.out.pack>
Traceback (most recent call last):
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/wsgi.py", line 109, in dispatch_request
return endpoint(request, **request.view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/protocols/dispatcher.py", line 43, in rpc
return methods.get(request.rpc_method, _dispatch)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/wsgi.py", line 75, in wrapper
return func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/protocols/wrappers.py", line 197, in wrapper
return func(request, pool, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/protocols/dispatcher.py", line 196, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/workflow.py", line 37, in wrapper
result = func(cls, filtered, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/modules/stock_package_shipping/stock.py", line 262, in pack
cls.check_no_carrier(shipments)
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/modules/stock_package_shipping/stock.py", line 222, in check_no_carrier
if Warning.check(name):
^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/res/user.py", line 1097, in check
cls.delete([x for x in warnings if not x.always])
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelsql.py", line 262, in wrapper
return func(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelsql.py", line 1516, in delete
super(ModelSQL, cls).delete(list(sub_records))
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/model/modelstorage.py", line 325, in delete
ModelAccess.check(cls.__name__, 'delete')
File "/home/mrichez/Workspace/tryton/issues/tryton_70_dev/trytond/trytond/ir/model.py", line 634, in check
raise AccessError(gettext(
trytond.model.modelstorage.AccessError: You are not allowed to access "User Warning". -
20506 139639436334784 [2024-03-26 10:44:58,378] INFO werkzeug 127.0.0.1 - - [26/Mar/2024 10:44:58] "POST /tryton_preciball_prod_70_test/ HTTP/1.1" 200
Edited by Maxime Richez