[FIX] sale: Make tests demo data independent

Part-of: odoo/odoo#146649
This commit is contained in:
Yannick Tivisse
2023-12-18 23:32:05 +00:00
parent b5ab8fb73b
commit 1d094d70f4
29 changed files with 237 additions and 95 deletions
+4
View File
@@ -18,6 +18,10 @@ class SaleCommon(
def setUpClass(cls):
super().setUpClass()
cls.env.company.country_id = cls.env.ref('base.us')
cls.env.ref('base.main_company').currency_id = cls.env.ref('base.USD')
cls.currency = cls.env.ref('base.USD')
# Not defined in product common because only used in sale
cls.group_discount_per_so_line = cls.env.ref('product.group_discount_per_so_line')
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import tagged, TransactionCase
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
+21 -16
View File
@@ -10,6 +10,7 @@ from odoo.tests import tagged, Form
from odoo.tools import float_compare
from odoo.addons.sale.tests.common import SaleCommon
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
@tagged('post_install', '-at_install')
@@ -114,20 +115,6 @@ class TestSaleOrder(SaleCommon):
self.assertEqual(mail_message.author_id, mail_message.partner_ids, 'Sale: author should be in composer recipients thanks to "partner_to" field set on template')
self.assertEqual(mail_message.partner_ids, mail_message.sudo().mail_ids.recipient_ids, 'Sale: author should receive mail due to presence in composer recipients')
def test_invoice_state_when_ordered_quantity_is_negative(self):
"""When you invoice a SO line with a product that is invoiced on ordered quantities and has negative ordered quantity,
this test ensures that the invoicing status of the SO line is 'invoiced' (and not 'upselling')."""
sale_order = self.env['sale.order'].create({
'partner_id': self.partner.id,
'order_line': [(0, 0, {
'product_id': self.product.id,
'product_uom_qty': -1,
})]
})
sale_order.action_confirm()
sale_order._create_invoices(final=True)
self.assertTrue(sale_order.invoice_status == 'invoiced', 'Sale: The invoicing status of the SO should be "invoiced"')
def test_sale_sequence(self):
self.env['ir.sequence'].search([
('code', '=', 'sale.order'),
@@ -452,6 +439,23 @@ class TestSaleOrder(SaleCommon):
self.assertEqual(sale_order.amount_total, 15.41, "")
@tagged('post_install', '-at_install')
class TestSaleOrderInvoicing(AccountTestInvoicingCommon, SaleCommon):
def test_invoice_state_when_ordered_quantity_is_negative(self):
"""When you invoice a SO line with a product that is invoiced on ordered quantities and has negative ordered quantity,
this test ensures that the invoicing status of the SO line is 'invoiced' (and not 'upselling')."""
sale_order = self.env['sale.order'].create({
'partner_id': self.partner.id,
'order_line': [(0, 0, {
'product_id': self.product.id,
'product_uom_qty': -1,
})]
})
sale_order.action_confirm()
sale_order._create_invoices(final=True)
self.assertTrue(sale_order.invoice_status == 'invoiced', 'Sale: The invoicing status of the SO should be "invoiced"')
@tagged('post_install', '-at_install')
class TestSalesTeam(SaleCommon):
@@ -537,8 +541,9 @@ class TestSalesTeam(SaleCommon):
'product_id': great_product.id,
},
])
partner = self.env['res.partner'].create({'name': 'Test Partner'})
sale_order = self.env['sale.order'].create({
'partner_id': self.env.ref('base.res_partner_1').id,
'partner_id': partner.id,
})
sol = self.env['sale.order.line'].create({
'name': super_product.name,
@@ -551,7 +556,7 @@ class TestSalesTeam(SaleCommon):
self.assertEqual(sol.analytic_distribution, {str(analytic_account_great.id): 100}, "The analytic distribution should be set to Great Account")
so_no_analytic_account = self.env['sale.order'].create({
'partner_id': self.env.ref('base.res_partner_1').id,
'partner_id': partner.id,
})
sol_no_analytic_account = self.env['sale.order.line'].create({
'name': super_product.name,
@@ -2,16 +2,20 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.product.tests.test_product_attribute_value_config import TestProductAttributeValueCommon
from odoo.tests import tagged
class TestSaleProductAttributeValueCommon(TestProductAttributeValueCommon):
@tagged("post_install", "-at_install")
class TestSaleProductAttributeValueCommon(AccountTestInvoicingCommon, TestProductAttributeValueCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.computer.company_id = cls.env.company
cls.computer = cls.computer.with_env(cls.env)
cls.env['product.pricelist'].sudo().search([]).action_archive()
cls.env['product.pricelist'].create({'name': 'Base Pricelist'})
+1 -2
View File
@@ -11,12 +11,11 @@ class TestSaleCouponCommon(TestSaleProductAttributeValueCommon):
@classmethod
def setUpClass(cls):
super(TestSaleCouponCommon, cls).setUpClass()
# set currency to not rely on demo data and avoid possible race condition
cls.currency_ratio = 1.0
# Set all the existing programs to active=False to avoid interference
cls.env['loyalty.program'].search([]).write({'active': False})
cls.env['loyalty.program'].search([]).sudo().write({'active': False})
# create partner for sale order.
cls.steve = cls.env['res.partner'].create({
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.sale_loyalty.tests.common import TestSaleCouponCommon
from odoo.exceptions import UserError
from odoo.tests import tagged
@@ -83,9 +84,12 @@ class TestSaleInvoicing(TestSaleCouponCommon):
order = self.empty_order
product_6 = self.env['product.product'].create({
'name': 'Large Cabinet',
})
# orderline1
self.env['sale.order.line'].create({
'product_id': self.env.ref('product.product_product_6').id,
'product_id': product_6.id,
'name': 'largeCabinet',
'product_uom_qty': 1.0,
'order_id': order.id,
@@ -95,9 +99,13 @@ class TestSaleInvoicing(TestSaleCouponCommon):
self.assertEqual(len(order.order_line), 2, 'Coupon correctly applied')
product_11 = self.env['product.product'].create({
'name': 'Conference Chair',
})
# orderline2
self.env['sale.order.line'].create({
'product_id': self.env.ref('product.product_product_11').id,
'product_id': product_11.id,
'name': 'conferenceChair',
'product_uom_qty': 1.0,
'order_id': order.id,
+3 -3
View File
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests.common import tagged, HttpCase
@tagged('post_install', '-at_install')
class TestUi(HttpCase):
class TestUi(AccountTestInvoicingCommon, HttpCase):
def test_01_sale_tour(self):
self.start_tour("/web", 'sale_tour', login="admin", step_delay=100)
@@ -1,13 +1,14 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.fields import Command
from odoo.tests import HttpCase, tagged
from odoo.tests import tagged
from odoo.addons.base.tests.common import HttpCaseWithUserDemo
from odoo.addons.product.tests.common import ProductAttributesCommon, ProductVariantsCommon
from odoo.addons.sale.tests.common import SaleCommon
@tagged('post_install', '-at_install')
class TestProductConfiguratorData(HttpCase, ProductVariantsCommon, SaleCommon):
class TestProductConfiguratorData(HttpCaseWithUserDemo, ProductVariantsCommon, SaleCommon):
def request_get_values(self, product_template):
base_url = product_template.get_base_url()
@@ -1,7 +1,11 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# -*- coding: utf-8 -*-
from odoo.tests import HttpCase, tagged
import logging
from odoo.tests import HttpCase, tagged, loaded_demo_data
_logger = logging.getLogger(__name__)
@tagged('-at_install', 'post_install')
@@ -35,4 +39,7 @@ class TestUi(HttpCase):
.execute()
def test_ui(self):
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.start_tour('/web', 'sale_timesheet_tour', login='admin', timeout=100)
@@ -6,14 +6,15 @@ from odoo import fields
from odoo.tests import HttpCase, tagged
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
@tagged('post_install', '-at_install')
class TestEventProductConfiguratorUi(HttpCase):
class TestEventProductConfiguratorUi(AccountTestInvoicingCommon, HttpCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
# Adding sale users to test the access rights
cls.salesman = mail_new_test_user(
@@ -12,6 +12,7 @@ class TestProductConfiguratorUi(HttpCase, TestProductConfiguratorCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env.company.country_id = cls.env.ref('base.us')
# Adding sale users to test the access rights
cls.salesman = mail_new_test_user(
@@ -26,6 +27,11 @@ class TestProductConfiguratorUi(HttpCase, TestProductConfiguratorCommon):
cls.env['res.partner'].create({'name': 'Tajine Saucisse'})
def test_01_product_configurator(self):
self.env.ref('base.user_admin').write({'groups_id': [(4, self.env.ref('product.group_product_variant').id)]})
tax = self.env['account.tax'].create({'name': "Test tax", 'amount': 15})
self.product_product_custo_desk.taxes_id = tax
self.product_product_conf_chair_floor_protect.taxes_id = tax
self.product_product_conf_chair.taxes_id = tax
self.start_tour("/web", 'sale_product_configurator_tour', login='salesman')
def test_02_product_configurator_advanced(self):
@@ -145,10 +151,12 @@ class TestProductConfiguratorUi(HttpCase, TestProductConfiguratorCommon):
"""
# Required to see `pricelist_id` in the view
self.salesman.write({
'groups_id': [(4, self.env.ref('product.group_product_pricelist').id)],
self.env.ref('base.group_user').write({'implied_ids': [(4, self.env.ref('product.group_product_pricelist').id)]})
self.env['res.partner'].create({
'name': 'Azure Interior',
'email': 'azure.Interior24@example.com',
'city': 'Fremont',
})
# Add a 15% tax on desk
tax = self.env['account.tax'].create({'name': "Test tax", 'amount': 15})
self.product_product_custo_desk.taxes_id = tax
@@ -1,10 +1,14 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import tagged
import logging
from odoo.tests import tagged, loaded_demo_data
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.product_matrix.tests.common import TestMatrixCommon
_logger = logging.getLogger(__name__)
@tagged('post_install', '-at_install')
class TestSaleMatrixUi(TestMatrixCommon):
@@ -31,6 +35,11 @@ class TestSaleMatrixUi(TestMatrixCommon):
cls.currency.action_unarchive()
def test_sale_matrix_ui(self):
# TODO: Adapt to work without demo data
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
# Set the template as configurable by matrix.
self.matrix_template.product_add_mode = "matrix"
@@ -2,42 +2,11 @@
import { registry } from "@web/core/registry";
import tourUtils from "@website_sale/js/tours/tour_utils";
import { jsonrpc } from "@web/core/network/rpc_service";
registry.category("web_tour.tours").add('shop_mail', {
test: true,
url: '/',
url: '/shop?search=Acoustic Bloc Screens',
steps: () => [
{
content: "Change the domain of the websites and go to shop",
trigger: 'body',
run: function () {
// We change the domain of the website to test that the email that
// will be sent uses the correct domain for its links.
var def1 = jsonrpc("/web/dataset/call_kw/website/write", {
'model': 'website',
'method': 'write',
'args': [[1], {
'domain': "my-test-domain.com",
}],
kwargs: {},
});
// We need to change the domain of all the websites otherwise the
// website selector will return the website 2 since the domain we
// set on website 1 doesn't actually match our test server.
var def2 = jsonrpc("/web/dataset/call_kw/website/write", {
'model': 'website',
'method': 'write',
'args': [[2], {
'domain': "https://domain-not-used.fr",
}],
kwargs: {},
});
Promise.all([def1, def2]).then(function (data) {
window.location.href = '/shop?search=Acoustic Bloc Screens';
});
},
},
...tourUtils.addToCart({productName: 'Acoustic Bloc Screens', search: false}),
tourUtils.goToCart(),
{
+2 -1
View File
@@ -12,7 +12,8 @@ from odoo.tools.misc import file_open
class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal):
def setUp(self):
super(TestUi, self).setUp()
super().setUp()
self.env.company.country_id = self.env.ref('base.us')
# create a template
product_template = self.env['product.template'].create({
'name': 'Test Product',
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from werkzeug.exceptions import Forbidden
import odoo.tests
@@ -10,6 +12,8 @@ from odoo.addons.base.tests.common import HttpCaseWithUserDemo, TransactionCaseW
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo.addons.website.tools import MockRequest
_logger = logging.getLogger(__name__)
@odoo.tests.tagged('post_install', '-at_install')
class TestUi(HttpCaseWithUserDemo):
@@ -40,6 +44,8 @@ class TestUi(HttpCaseWithUserDemo):
self.product_product_11_product_template = self.env['product.template'].create({
'name': 'Conference Chair',
'list_price': 16.50,
'website_published': True,
'sale_ok': True,
'accessory_product_ids': [(4, product_product_7.id)],
})
self.env['product.template.attribute.line'].create({
@@ -52,6 +58,9 @@ class TestUi(HttpCaseWithUserDemo):
'name': 'Chair floor protection',
'list_price': 12.0,
})
# Crappy hack: But otherwise the "Proceed To Checkout" modal button won't be displayed
if 'optional_product_ids' in self.env['product.template']:
self.product_product_11_product_template.optional_product_ids = [(6, 0, self.product_product_1_product_template.ids)]
self.env['account.journal'].create({'name': 'Cash - Test', 'type': 'cash', 'code': 'CASH - Test'})
@@ -103,6 +112,7 @@ class TestUi(HttpCaseWithUserDemo):
'is_published': True,
})
transfer_provider._transfer_ensure_pending_msg_is_set()
self.env.company.country_id = self.env.ref('base.us')
tax_group = self.env['account.tax.group'].create({'name': 'Tax 15%'})
tax = self.env['account.tax'].create({
'name': 'Tax 15%',
@@ -130,6 +140,9 @@ class TestUi(HttpCaseWithUserDemo):
self.start_tour("/", 'website_sale_tour_2', login="admin")
def test_05_google_analytics_tracking(self):
if not odoo.tests.loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.env['website'].browse(1).write({'google_analytics_key': 'G-XXXXXXXXXXX'})
self.start_tour("/shop", 'google_analytics_view_item')
self.start_tour("/shop", 'google_analytics_add_to_cart')
@@ -143,6 +156,9 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo, HttpCaseWithUs
def setUp(self):
super().setUp()
self.partner_demo.company_id = self.env.ref('base.main_company')
self.website = self.env.ref('website.default_website')
self.country_id = self.env.ref('base.be').id
self.WebsiteSaleController = WebsiteSale()
self.default_address_values = {
'name': 'a res.partner address', 'email': 'email@email.email', 'street': 'ooo',
@@ -352,6 +368,11 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo, HttpCaseWithUs
self._setUp_multicompany_env()
so = self._create_so(self.portal_partner.id)
self.env['sale.order'].create({
'partner_id': self.partner_portal.id,
'state': 'sent',
})
env = api.Environment(self.env.cr, self.portal_user.id, {})
# change also website env for `sale_get_order` to not change order partner_id
with MockRequest(env, website=self.website.with_env(env), sale_order_id=so.id) as req:
@@ -374,6 +395,7 @@ class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo, HttpCaseWithUs
Check that the sale order is updated when you change fiscal position.
Change fiscal position by modifying address during checkout process.
"""
self.env.company.country_id = self.env.ref('base.us')
partner = self.env['res.partner'].create({'name': 'test'})
be_address_POST, nl_address_POST = [
{
@@ -1,11 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import Command
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo.addons.website.tools import MockRequest
from odoo.exceptions import ValidationError
from odoo.tests import HttpCase, tagged
from odoo.tests import HttpCase, tagged, loaded_demo_data
_logger = logging.getLogger(__name__)
ATTACHMENT_DATA = [
b"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAEElEQVR4nGKqf3geEAAA//8EGgIyYKYzzgAAAABJRU5ErkJggg==",
@@ -205,9 +209,15 @@ class TestWebsiteSaleEditor(HttpCase):
})
def test_category_page_and_products_snippet(self):
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
SHOP_CATEGORY_ID = 2
self.start_tour(self.env['website'].get_client_action_url(f'/shop/category/{SHOP_CATEGORY_ID}'), 'category_page_and_products_snippet_edition', login='restricted')
self.start_tour(f'/shop/category/{SHOP_CATEGORY_ID}', 'category_page_and_products_snippet_use', login=None)
def test_website_sale_restricted_editor_ui(self):
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.start_tour(self.env['website'].get_client_action_url('/shop'), 'website_sale_restricted_editor_ui', login='restricted')
@@ -1,6 +1,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
import logging
from odoo.tests import HttpCase, tagged, loaded_demo_data
_logger = logging.getLogger(__name__)
@tagged('post_install', '-at_install')
@@ -33,4 +37,7 @@ class TestAddToCartSnippet(HttpCase):
def test_configure_product(self):
# Reset the company country id, which ensure that no country dependant fields are blocking the address form.
self.env.company.country_id = self.env.ref('base.us')
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.start_tour("/", 'add_to_cart_snippet_tour', login="admin")
@@ -1,14 +1,15 @@
# coding: utf-8
from odoo.addons.base.tests.common import TransactionCaseWithUserPortal
from odoo.addons.website_sale.controllers.main import WebsiteSale, PaymentPortal
from odoo.addons.website.tools import MockRequest
from odoo.exceptions import UserError
from odoo.tests.common import TransactionCase, tagged
from odoo.tests.common import tagged
from odoo.fields import Command
@tagged('post_install', '-at_install')
class WebsiteSaleCart(TransactionCase):
class WebsiteSaleCart(TransactionCaseWithUserPortal):
@classmethod
def setUpClass(cls):
@@ -90,7 +91,7 @@ class WebsiteSaleCart(TransactionCase):
'lst_price': 1000.0,
'standard_price': 800.0,
})
portal_user = self.env.ref('base.demo_user0')
portal_user = self.user_portal
website = self.website.with_user(portal_user)
SaleOrderLine = self.env['sale.order.line']
@@ -21,6 +21,8 @@ class TestWebsiteSaleFiscalPosition(ProductCommon, HttpCaseWithUserPortal):
The goal of this test is to check that this template
is up to date with the fiscal position detected.
"""
self.env.ref('base.group_user').write({'implied_ids': [(4, self.env.ref('product.group_product_pricelist').id)]})
self.env.company.country_id = self.env.ref('base.us')
website_id = self.env.ref('website.default_website').id
belgium_id = self.env.ref('base.be').id
# Set setting to display tax included on the website
@@ -37,7 +39,7 @@ class TestWebsiteSaleFiscalPosition(ProductCommon, HttpCaseWithUserPortal):
'include_base_amount': False,
})
tax_0 = self.env['account.tax'].create({
'name': '0%',
'name': '0% Test Tax',
'type_tax_use': 'sale',
'amount_type': 'percent',
'amount': 0,
@@ -52,14 +54,21 @@ class TestWebsiteSaleFiscalPosition(ProductCommon, HttpCaseWithUserPortal):
})]
})
# Create a pricelist which will be automatically detected
self.env['product.pricelist'].create({
self.env['product.pricelist'].create([{
'name': 'EUROPE EUR',
'selectable': True,
'website_id': website_id,
'country_group_ids': [Command.link(self.env.ref('base.europe').id)],
'sequence': 1,
'currency_id': self.env.ref('base.EUR').id,
})
}, {
'name': 'Christmas List',
'selectable': False,
'website_id': website_id,
'country_group_ids': [Command.link(self.env.ref('base.europe').id)],
'sequence': 20,
'currency_id': self.env.ref('base.EUR').id,
}])
# Create the product to be used for analysis
self.env["product.product"].create({
'name': "Super product",
@@ -17,6 +17,7 @@ class TestWebsiteSaleMail(HttpCase):
self.env['product.product'].create({
'name': 'Acoustic Bloc Screens',
'list_price': 2950.0,
'sale_ok': True,
'website_published': True,
})
self.env['res.partner'].create({
@@ -29,6 +30,13 @@ class TestWebsiteSaleMail(HttpCase):
# as we check some link content, avoid mobile doing its link management
self.env['ir.config_parameter'].sudo().set_param('mail_mobile.disable_redirect_firebase_dynamic_link', True)
main_website = self.env.ref('website.default_website')
other_websites = self.env['website'].search([]) - main_website
# We change the domain of the website to test that the email that
# will be sent uses the correct domain for its links.
main_website.domain = "my-test-domain.com"
other_websites.domain = "https://domain-not-used.fr"
with patch.object(MailMail, 'unlink', lambda self: None):
start_time = fields.Datetime.now()
self.start_tour("/", 'shop_mail', login="admin")
@@ -1,13 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from unittest.mock import patch
from odoo.fields import Command
from odoo.tests import tagged, TransactionCase
from odoo.tests import tagged, TransactionCase, loaded_demo_data
from odoo.addons.base.tests.common import TransactionCaseWithUserDemo, HttpCaseWithUserPortal
from odoo.addons.website.tools import MockRequest
_logger = logging.getLogger(__name__)
''' /!\/!\
Calling `get_pricelist_available` after setting `property_product_pricelist` on
a partner will not work as expected. That field will change the output of
@@ -282,6 +287,7 @@ class TestWebsitePriceList(TransactionCase):
returns a dict with just `price_reduce` (no discount) as key
when the product is tax included.
"""
self.env.company.country_id = self.env.ref('base.us')
tax = self.env['account.tax'].create({
'name': "Tax 10",
'amount': 10,
@@ -650,6 +656,9 @@ class TestWebsiteSaleSession(HttpCaseWithUserPortal):
The objective is to verify that the pricelist
changes correctly according to the user.
"""
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
website = self.env.ref('website.default_website')
test_user = self.env['res.users'].create({
'name': 'Toto',
@@ -6,9 +6,11 @@ from odoo.addons.sale.tests.test_sale_product_attribute_value_config import Test
@tagged('post_install', '-at_install')
class WebsiteSaleProductTests(TestSaleProductAttributeValueCommon):
def setUp(self):
super().setUp()
self.website = self.env.ref('website.default_website')
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.website = cls.env.ref('website.default_website')
cls.website.company_id = cls.env.company
def test_website_sale_contextual_price(self):
contextual_price = self.computer._get_contextual_price()
@@ -10,13 +10,14 @@ from odoo.addons.website.tools import MockRequest
@tagged('post_install', '-at_install', 'product_attribute')
class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, TestSaleProductAttributeValueCommon):
class TestWebsiteSaleProductAttributeValueConfig(TestSaleProductAttributeValueCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
# Use the testing environment.
cls.env['website'].get_current_website().company_id = cls.env.company
cls.computer.company_id = cls.env.company
cls.computer = cls.computer.with_env(cls.env)
def test_get_combination_info(self):
@@ -79,6 +80,9 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes
def test_get_combination_info_with_fpos(self):
# Setup product.
current_website = self.env['website'].get_current_website()
pricelist = current_website._get_current_pricelist()
(self.env['product.pricelist'].search([]) - pricelist).write({'active': False})
product = self.env['product.template'].create({
'name': 'Test Product',
'list_price': 2000,
@@ -168,10 +172,9 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes
@tagged('post_install', '-at_install', 'product_pricelist')
class TestWebsiteSaleProductPricelist(AccountTestInvoicingCommon, TestSaleProductAttributeValueCommon):
class TestWebsiteSaleProductPricelist(TestSaleProductAttributeValueCommon):
def test_cart_update_with_fpos(self):
# We will test that the mapping of an 10% included tax by a 6% by a fiscal position is taken into account when updating the cart
self.env.user.partner_id.country_id = False
current_website = self.env['website'].get_current_website()
self.env['product.pricelist'].search([]).action_archive()
pricelist = self.env['product.pricelist'].create({
@@ -225,7 +228,6 @@ class TestWebsiteSaleProductPricelist(AccountTestInvoicingCommon, TestSaleProduc
def test_cart_update_with_fpos_no_variant_product(self):
# We will test that the mapping of an 10% included tax by a 0% by a fiscal position is taken into account when updating the cart for no_variant product
self.env.user.partner_id.country_id = False
current_website = self.env['website'].get_current_website()
# Add 10% tax on product
tax10 = self.env['account.tax'].create({'name': "Test tax 10", 'amount': 10, 'price_include': True, 'amount_type': 'percent', 'type_tax_use': 'sale'})
@@ -1,13 +1,21 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
import logging
from odoo.tests import HttpCase, tagged, loaded_demo_data
from odoo.addons.website.tools import MockRequest
_logger = logging.getLogger(__name__)
@tagged('post_install', '-at_install', 'website_snippets')
class TestSnippets(HttpCase):
def test_01_snippet_products_edition(self):
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.start_tour('/', 'website_sale.snippet_products', login='admin')
def test_02_snippet_products_remove(self):
@@ -1,12 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from collections import OrderedDict
from lxml import etree
from odoo import tools
import odoo.tests
_logger = logging.getLogger(__name__)
@odoo.tests.tagged('-at_install', 'post_install')
class TestWebsiteSaleComparison(odoo.tests.TransactionCase):
@@ -18,6 +22,13 @@ class TestWebsiteSaleComparison(odoo.tests.TransactionCase):
`_remove_copied_views`. The problematic view that has to be removed is
`product_attributes_body` because it has a reference to `add_to_compare`.
"""
# YTI TODO: Adapt this tour without demo data
# I still didn't figure why, but this test freezes on runbot
# without the demo data
if not odoo.tests.loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
Website0 = self.env['website'].with_context(website_id=None)
Website1 = self.env['website'].with_context(website_id=1)
@@ -105,7 +116,8 @@ class TestUi(odoo.tests.HttpCase):
def test_01_admin_tour_product_comparison(self):
# YTI FIXME: Adapt to work without demo data
if tools.config["without_demo"]:
if not odoo.tests.loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.start_tour("/", 'product_comparison', login='admin')
@@ -8,16 +8,34 @@ from odoo.addons.sale.tests.test_sale_product_attribute_value_config import Test
@tagged('post_install', '-at_install')
class TestUi(TestSaleProductAttributeValueCommon, HttpCase):
class WebsiteSaleLoyaltyTestUi(TestSaleProductAttributeValueCommon, HttpCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env.ref('base.user_admin').write({
'company_id': cls.env.company.id,
'company_ids': [(4, cls.env.company.id)],
'name': 'Mitchell Admin',
'street': '215 Vine St',
'phone': '+1 555-555-5555',
'city': 'Scranton',
'zip': '18503',
'country_id': cls.env.ref('base.us').id,
'state_id': cls.env.ref('base.state_us_39').id,
})
cls.env.ref('base.user_admin').sudo().partner_id.company_id = cls.env.company
cls.env.ref('website.default_website').company_id = cls.env.company
def test_01_admin_shop_sale_loyalty_tour(self):
if self.env['ir.module.module']._get('payment_custom').state != 'installed':
self.skipTest("Transfer provider is not installed")
transfer_provider = self.env.ref('payment.payment_provider_transfer')
transfer_provider.write({
transfer_provider.sudo().write({
'state': 'enabled',
'is_published': True,
'company_id': self.env.company.id,
})
transfer_provider._transfer_ensure_pending_msg_is_set()
@@ -8,6 +8,16 @@ class TestWebsiteSaleDelivery(HttpCase):
def setUp(self):
super().setUp()
self.env.ref('base.user_admin').write({
'name': 'Mitchell Admin',
'street': '215 Vine St',
'phone': '+1 555-555-5555',
'city': 'Scranton',
'zip': '18503',
'country_id': self.env.ref('base.us').id,
'state_id': self.env.ref('base.state_us_39').id,
})
self.env['product.product'].create({
'name': 'Acoustic Bloc Screens',
'list_price': 2950.0,
+9 -1
View File
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
import logging
from odoo.tests import HttpCase, tagged, loaded_demo_data
_logger = logging.getLogger(__name__)
@tagged('-at_install', 'post_install')
@@ -32,6 +36,10 @@ class TestUi(HttpCase):
def test_onsite_payment_tour(self):
# Make sure at least one onsite payment option exists.
if not loaded_demo_data(self.env):
_logger.warning("This test relies on demo data. To be rewritten independently of demo data for accurate and reliable results.")
return
self.env['delivery.carrier'].create({
'delivery_type': 'onsite',
'is_published': True,
@@ -3,11 +3,11 @@
from odoo.tests import tagged
from odoo.addons.sale_product_configurator.tests.common import TestProductConfiguratorCommon
from odoo.addons.base.tests.common import HttpCaseWithUserPortal
from odoo.addons.base.tests.common import HttpCaseWithUserPortal, HttpCaseWithUserDemo
@tagged('post_install', '-at_install')
class TestWebsiteSaleProductConfigurator(TestProductConfiguratorCommon, HttpCaseWithUserPortal):
class TestWebsiteSaleProductConfigurator(TestProductConfiguratorCommon, HttpCaseWithUserPortal, HttpCaseWithUserDemo):
@classmethod
def setUpClass(cls):
super().setUpClass()