OCA/website

website_odoo_debranding: Since Odoo 15.0, Environment.manage() is useless

Closed this issue · 0 comments

dhx commented

In our 15.0 tests we see this warning:

/usr/lib/python3.8/contextlib.py:113: DeprecationWarning: Since Odoo 15.0, Environment.manage() is useless.
  File "odoo/odoo-bin", line 8, in <module>
    odoo.cli.main()
  File "/data/build/odoo/odoo/cli/command.py", line 61, in main
    o.run(args)
  File "/data/build/odoo/odoo/cli/server.py", line 179, in run
    main(args)
  File "/data/build/odoo/odoo/cli/server.py", line 173, in main
    rc = odoo.service.server.start(preload=preload, stop=stop)
  File "/data/build/odoo/odoo/service/server.py", line 1356, in start
    rc = server.run(preload, stop)
  File "/data/build/odoo/odoo/service/server.py", line 557, in run
    rc = preload_registries(preload)
  File "/data/build/odoo/odoo/service/server.py", line 1260, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/data/build/odoo/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/data/build/odoo/odoo/modules/loading.py", line 474, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/data/build/odoo/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/data/build/odoo/odoo/modules/loading.py", line 240, in load_module_graph
    getattr(py_module, post_init)(cr, registry)
  File "/data/build/addons-oca/addons/website_odoo_debranding/hooks.py", line 17, in post_init_hook
    with api.Environment.manage():
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)

which seems to be triggered by:

https://github.com/OCA/website/blob/15.0/website_odoo_debranding/hooks.py#L17

Related to #898