OCA / website

Odoo website builder addons
GNU Affero General Public License v3.0
254 stars 690 forks source link

[14.0] [FIX] website_require_login: hidden exception #1036

Closed renda-dev closed 4 months ago

renda-dev commented 4 months ago

Fixed an issue where if an exception has been raised, it would try to access a closed cursor, causing the disconnection and re-connection from the website, totally hiding the exception message.

Traceback (partial):

File "/opt/odoo/custom/src/odoo/odoo/service/wsgi_server.py", line 113, in application
  return application_unproxied(environ, start_response)
File "/opt/odoo/custom/src/odoo/odoo/service/wsgi_server.py", line 88, in application_unproxied
  result = odoo.http.root(environ, start_response)
File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1341, in __call__
  return self.dispatch(environ, start_response)
File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1307, in __call__
  return self.app(environ, start_wrapped)
File "/usr/local/lib/python3.8/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
  return self.app(environ, start_response)
File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1530, in dispatch
  result = ir_http._dispatch()
File "/opt/odoo/custom/src/website/website_require_login/models/ir_http.py", line 21, in _dispatch
  if request.uid == website.user_id.id:
File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 2494, in __get__
  return super().__get__(records, owner)
File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1020, in __get__
  recs._fetch_field(self)
File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3085, in _fetch_field
  self._read(fnames)
File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3152, in _read
  cr.execute(query_str, params + [sub_ids])
File "<decorator-gen-5>", line 2, in execute

File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 101, in check
  return f(self, *args, **kwargs)
File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 301, in execute
  res = self._obj.execute(query, params)
psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block

pre-commit is fixed in: https://github.com/OCA/website/pull/1037

francesco-ooops commented 4 months ago

@pedrobaeza good for you?

renda-dev commented 4 months ago

Thanks for the feedback @pedrobaeza, I've addressed all of the issues, could you please give it another look?

OCA-git-bot commented 4 months ago

This PR looks fantastic, let's merge it! Prepared branch 14.0-ocabot-merge-pr-1036-by-pedrobaeza-bump-patch, awaiting test results.

OCA-git-bot commented 4 months ago

Congratulations, your PR was merged at 399ca0dc898d51409b4e974d39d831016a07295a. Thanks a lot for contributing to OCA. ❤️