Skip to content

Commit

Permalink
[FIX] website_sale_checkout_skip_payment: CacheMiss error when sessio…
Browse files Browse the repository at this point in the history
…n is not authenticated

[FIX] website_sale_checkout_skip_payment: CacheMiss error when session is not authenticated
  • Loading branch information
tarteo authored and pilarvargas-tecnativa committed Oct 22, 2024
1 parent b24261c commit bd48517
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 6 additions & 3 deletions website_sale_checkout_skip_payment/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Website(models.Model):

def _compute_checkout_skip_payment(self):
for rec in self:
rec.checkout_skip_payment = (
request.env.user.partner_id.skip_website_checkout_payment
)
if request.session.uid:
rec.checkout_skip_payment = (
request.env.user.partner_id.skip_website_checkout_payment
)
else:
rec.checkout_skip_payment = False
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2018 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import mock

from odoo.tests.common import HttpCase


Expand All @@ -12,6 +14,14 @@ def setUp(self):
{"skip_website_checkout_payment": True}
)

def test_checkout_skip_payment(self):
website = self.env.ref("website.website2")
with mock.patch(
"odoo.addons.website_sale_checkout_skip_payment.models.website.request"
) as request:
request.session.uid = False
self.assertFalse(website.checkout_skip_payment)

def test_ui_website(self):
"""Test frontend tour."""
tour = (
Expand Down

0 comments on commit bd48517

Please sign in to comment.