From 56a9e9f49ac2b68a6be0b3f1f371b0dd11d0265f Mon Sep 17 00:00:00 2001 From: vava-odoo Date: Mon, 8 Jan 2024 16:28:05 +0000 Subject: [PATCH] [FIX] website_sale(_stock): move test due to dependency to stock In odoo@98ca5140baf96, a test using a product of type 'product' was added. Since this type is introduced in stock, stock needs be installed. Since the delivery module was split in saas-16.2 to remove the dependency to stock, this test needs to be moved in website_sale_stock. Build error 48757 closes odoo/odoo#148691 X-original-commit: c517b45eb36b02c2f0679be79da565087c5e48ca Signed-off-by: Vallaeys Valentin (vava) --- .../tests/test_delivery_controller.py | 22 +---------- addons/website_sale_stock/tests/__init__.py | 1 + .../tests/test_website_sale_stock_delivery.py | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 addons/website_sale_stock/tests/test_website_sale_stock_delivery.py diff --git a/addons/website_sale/tests/test_delivery_controller.py b/addons/website_sale/tests/test_delivery_controller.py index e1690100b03..fe8624eeb5b 100644 --- a/addons/website_sale/tests/test_delivery_controller.py +++ b/addons/website_sale/tests/test_delivery_controller.py @@ -3,7 +3,7 @@ from unittest.mock import patch from odoo.fields import Command -from odoo.exceptions import UserError, ValidationError +from odoo.exceptions import UserError from odoo.tests import tagged from odoo.addons.payment.tests.common import PaymentCommon @@ -110,23 +110,3 @@ class TestWebsiteSaleDeliveryController(PaymentCommon, SaleCommon): self.assertEqual( self.empty_order._get_delivery_methods().mapped('name'), ['Under 300', 'Fixed'] ) - - def test_validate_payment_with_no_available_delivery_method(self): - """ - An error should be raised if you try to validate an order with a storable - product without any delivery method available - """ - storable_product = self.env['product.product'].create({ - 'name': 'Storable Product', - 'sale_ok': True, - 'type': 'product', - 'website_published': True, - }) - carriers = self.env['delivery.carrier'].search([]) - carriers.write({'website_published': False}) - - with MockRequest(self.env, website=self.website): - self.website.sale_get_order(force_create=True) - self.Controller.cart_update_json(product_id=storable_product.id, add_qty=1) - with self.assertRaises(ValidationError): - self.Controller.shop_payment_validate() diff --git a/addons/website_sale_stock/tests/__init__.py b/addons/website_sale_stock/tests/__init__.py index 73401d0fc2a..8ede39c2e36 100644 --- a/addons/website_sale_stock/tests/__init__.py +++ b/addons/website_sale_stock/tests/__init__.py @@ -4,6 +4,7 @@ from . import test_website_sale_stock_abandoned_cart_email from . import test_website_sale_stock_multilang from . import test_website_sale_stock_product_warehouse +from . import test_website_sale_stock_delivery from . import test_website_sale_stock_stock_notification from . import test_website_sale_stock_reorder_from_portal from . import test_website_sale_stock_stock_message diff --git a/addons/website_sale_stock/tests/test_website_sale_stock_delivery.py b/addons/website_sale_stock/tests/test_website_sale_stock_delivery.py new file mode 100644 index 00000000000..69d450fec1a --- /dev/null +++ b/addons/website_sale_stock/tests/test_website_sale_stock_delivery.py @@ -0,0 +1,37 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import tagged + +from odoo.addons.payment.tests.common import PaymentCommon +from odoo.addons.sale.tests.common import SaleCommon +from odoo.addons.website.tools import MockRequest +from odoo.addons.website_sale.controllers.delivery import WebsiteSaleDelivery +from odoo.exceptions import ValidationError + + +@tagged('post_install', '-at_install') +class TestWebsiteSaleStockDeliveryController(PaymentCommon, SaleCommon): + def setUp(self): + super().setUp() + self.website = self.env.ref('website.default_website') + self.Controller = WebsiteSaleDelivery() + + def test_validate_payment_with_no_available_delivery_method(self): + """ + An error should be raised if you try to validate an order with a storable + product without any delivery method available + """ + storable_product = self.env['product.product'].create({ + 'name': 'Storable Product', + 'sale_ok': True, + 'type': 'product', + 'website_published': True, + }) + carriers = self.env['delivery.carrier'].search([]) + carriers.write({'website_published': False}) + + with MockRequest(self.env, website=self.website): + self.website.sale_get_order(force_create=True) + self.Controller.cart_update_json(product_id=storable_product.id, add_qty=1) + with self.assertRaises(ValidationError): + self.Controller.shop_payment_validate()