[IMP] website_sale: Adapt tests to work with/without demo data
This commit is contained in:
@@ -6,12 +6,12 @@ odoo.define('website_sale_tour.tour', function (require) {
|
||||
|
||||
tour.register('website_sale_tour', {
|
||||
test: true,
|
||||
url: '/shop?search=Storage Box',
|
||||
url: '/shop?search=Storage Box Test',
|
||||
}, [
|
||||
// Testing b2c with Tax-Excluded Prices
|
||||
{
|
||||
content: "Open product page",
|
||||
trigger: '.oe_product_cart a:contains("Storage Box")',
|
||||
trigger: '.oe_product_cart a:contains("Storage Box Test")',
|
||||
},
|
||||
{
|
||||
content: "Add one more storage box",
|
||||
@@ -28,7 +28,7 @@ odoo.define('website_sale_tour.tour', function (require) {
|
||||
},
|
||||
{
|
||||
content: "Check for 2 products in cart and proceed to checkout",
|
||||
extra_trigger: '#cart_products tr:contains("Storage Box") input.js_quantity:propValue(2)',
|
||||
extra_trigger: '#cart_products tr:contains("Storage Box Test") input.js_quantity:propValue(2)',
|
||||
trigger: 'a[href*="/shop/checkout"]',
|
||||
},
|
||||
{
|
||||
@@ -196,17 +196,17 @@ odoo.define('website_sale_tour.tour', function (require) {
|
||||
});
|
||||
});
|
||||
def2.then(function () {
|
||||
window.location.href = '/web/session/logout?redirect=/shop?search=Storage Box';
|
||||
window.location.href = '/web/session/logout?redirect=/shop?search=Storage Box Test';
|
||||
});
|
||||
},
|
||||
},
|
||||
// Testing b2b with Tax-Included Prices
|
||||
{
|
||||
content: "Open product page",
|
||||
trigger: '.oe_product_cart a:contains("Storage Box")',
|
||||
trigger: '.oe_product_cart a:contains("Storage Box Test")',
|
||||
},
|
||||
{
|
||||
content: "Add one more Storage Box",
|
||||
content: "Add one more Storage Box Test",
|
||||
trigger: '.js_add_cart_json:eq(1)',
|
||||
},
|
||||
{
|
||||
@@ -220,7 +220,7 @@ odoo.define('website_sale_tour.tour', function (require) {
|
||||
},
|
||||
{
|
||||
content: "Check for 2 products in cart and proceed to checkout",
|
||||
extra_trigger: '#cart_products tr:contains("Storage Box") input.js_quantity:propValue(2)',
|
||||
extra_trigger: '#cart_products tr:contains("Storage Box Test") input.js_quantity:propValue(2)',
|
||||
trigger: 'a[href*="/shop/checkout"]',
|
||||
},
|
||||
{
|
||||
@@ -344,13 +344,13 @@ odoo.define('website_sale_tour.tour', function (require) {
|
||||
run: function () {
|
||||
$('.oe_login_form input[name="login"]').val("abc@odoo.com");
|
||||
$('.oe_login_form input[name="password"]').val("1admin@admin");
|
||||
$('.oe_login_form input[name="redirect"]').val("/shop?search=Storage Box");
|
||||
$('.oe_login_form input[name="redirect"]').val("/shop?search=Storage Box Test");
|
||||
$('.oe_login_form').submit();
|
||||
},
|
||||
},
|
||||
{
|
||||
content: "Open product page",
|
||||
trigger: '.oe_product_cart a:contains("Storage Box")',
|
||||
trigger: '.oe_product_cart a:contains("Storage Box Test")',
|
||||
},
|
||||
{
|
||||
content: "Click on add to cart",
|
||||
|
||||
@@ -8,9 +8,9 @@ odoo.define("website_sale.tour_shop_custom_attribute_value", function (require)
|
||||
test: true,
|
||||
}, [{
|
||||
content: "click on Customizable Desk",
|
||||
trigger: '.oe_product_cart a:contains("Customizable Desk")',
|
||||
trigger: '.oe_product_cart a:contains("Customizable Desk (TEST)")',
|
||||
}, {
|
||||
trigger: 'li.js_attribute_value span:contains(Custom)',
|
||||
trigger: 'li.js_attribute_value span:contains(Custom TEST)',
|
||||
extra_trigger: 'li.js_attribute_value',
|
||||
run: 'click',
|
||||
}, {
|
||||
@@ -21,7 +21,7 @@ odoo.define("website_sale.tour_shop_custom_attribute_value", function (require)
|
||||
trigger: 'a:contains(Add to Cart)',
|
||||
run: 'click',
|
||||
}, {
|
||||
trigger: 'span:contains(Custom: Wood)',
|
||||
trigger: 'span:contains(Custom TEST: Wood)',
|
||||
extra_trigger: '#cart_products',
|
||||
run: function (){}, // check
|
||||
}]);
|
||||
|
||||
@@ -19,11 +19,11 @@ odoo.define('website_sale.tour_shop_customize', function (require) {
|
||||
{
|
||||
content: "select product attribute Steel",
|
||||
extra_trigger: 'body:not(:has(#customize-menu:visible .dropdown-menu:visible))',
|
||||
trigger: 'form.js_attributes label:contains(Steel) input:not(:checked)',
|
||||
trigger: 'form.js_attributes label:contains(Steel - Test) input:not(:checked)',
|
||||
},
|
||||
{
|
||||
content: "check the selection",
|
||||
trigger: 'form.js_attributes label:contains(Steel) input:checked',
|
||||
trigger: 'form.js_attributes label:contains(Steel - Test) input:checked',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
{
|
||||
@@ -31,36 +31,10 @@ odoo.define('website_sale.tour_shop_customize', function (require) {
|
||||
extra_trigger: 'body:not(:has(.oe_website_sale .oe_product_cart:eq(3)))',
|
||||
trigger: '.oe_product_cart a:contains("Test Product")',
|
||||
},
|
||||
{
|
||||
content: "open customize menu",
|
||||
trigger: '#customize-menu',
|
||||
extra_trigger: "#product_detail",
|
||||
run: function() {
|
||||
// ENABLE VARIANT GROUP
|
||||
$('body').addClass('notReady');
|
||||
var ajax = odoo.__DEBUG__.services['web.ajax'];
|
||||
var get_group_payload = {
|
||||
model: 'ir.model.data',
|
||||
method: 'xmlid_to_res_id',
|
||||
args: ['product.group_product_variant', false],
|
||||
kwargs: {}
|
||||
};
|
||||
ajax.jsonRpc('/web/dataset/call_kw', 'call', get_group_payload).then(function(group_id) {
|
||||
ajax.jsonRpc('/web/dataset/call_kw', 'call', {
|
||||
model: 'res.groups',
|
||||
method: 'write',
|
||||
args: [group_id, {'users': [[4, 1]]}],
|
||||
kwargs: {}
|
||||
}).then(function() {
|
||||
location.reload(true);
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
content: "open customize menu",
|
||||
trigger: '#customize-menu > a',
|
||||
extra_trigger: 'body:not(.notReady)',
|
||||
extra_trigger: '#product_detail',
|
||||
},
|
||||
{
|
||||
content: "check page loaded after enable variant group",
|
||||
@@ -129,7 +103,7 @@ odoo.define('website_sale.tour_shop_customize', function (require) {
|
||||
},
|
||||
{
|
||||
content: "switch back to Steel variant",
|
||||
trigger: ".js_product label:contains('Steel')",
|
||||
trigger: ".js_product label:contains('Steel - Test')",
|
||||
},
|
||||
{
|
||||
content: "check price is 750",
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_customize
|
||||
from . import test_sale_process
|
||||
from . import test_sitemap
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import odoo.tests
|
||||
import base64
|
||||
|
||||
from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal
|
||||
from odoo.modules.module import get_module_resource
|
||||
from odoo.tests import tagged
|
||||
|
||||
@odoo.tests.common.tagged('post_install', '-at_install')
|
||||
class TestUi(odoo.tests.HttpCase):
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal):
|
||||
|
||||
def setUp(self):
|
||||
super(TestUi, self).setUp()
|
||||
@@ -18,9 +21,20 @@ class TestUi(odoo.tests.HttpCase):
|
||||
tax = self.env['account.tax'].create({'name': "Test tax", 'amount': 10})
|
||||
product_template.taxes_id = tax
|
||||
|
||||
product_attribute = self.env.ref('product.product_attribute_1')
|
||||
product_attribute_value_1 = self.env.ref('product.product_attribute_value_1')
|
||||
product_attribute_value_2 = self.env.ref('product.product_attribute_value_2')
|
||||
product_attribute = self.env['product.attribute'].create({
|
||||
'name': 'Legs',
|
||||
'sequence': 10,
|
||||
})
|
||||
product_attribute_value_1 = self.env['product.attribute.value'].create({
|
||||
'name': 'Steel - Test',
|
||||
'attribute_id': product_attribute.id,
|
||||
'sequence': 1,
|
||||
})
|
||||
product_attribute_value_2 = self.env['product.attribute.value'].create({
|
||||
'name': 'Aluminium',
|
||||
'attribute_id': product_attribute.id,
|
||||
'sequence': 2,
|
||||
})
|
||||
|
||||
# set attribute and attribute values on the template
|
||||
self.env['product.template.attribute.line'].create([{
|
||||
@@ -34,17 +48,99 @@ class TestUi(odoo.tests.HttpCase):
|
||||
.search([('product_tmpl_id', '=', product_template.id)])
|
||||
|
||||
for ptav in product_template_attribute_values:
|
||||
if ptav.name == "Steel":
|
||||
if ptav.name == "Steel - Test":
|
||||
ptav.price_extra = 0
|
||||
else:
|
||||
ptav.price_extra = 50.4
|
||||
|
||||
def test_01_admin_shop_customize_tour(self):
|
||||
# Enable Variant Group
|
||||
self.env.ref('product.group_product_variant').write({'users': [(4, self.env.ref('base.user_admin').id)]})
|
||||
self.start_tour("/", 'shop_customize', login="admin")
|
||||
|
||||
def test_02_admin_shop_custom_attribute_value_tour(self):
|
||||
# Make sure pricelist rule exist
|
||||
product_template = self.env.ref('product.product_product_4_product_template')
|
||||
self.product_attribute_1 = self.env['product.attribute'].create({
|
||||
'name': 'Legs',
|
||||
'sequence': 10,
|
||||
})
|
||||
product_attribute_value_1 = self.env['product.attribute.value'].create({
|
||||
'name': 'Steel',
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'sequence': 1,
|
||||
})
|
||||
product_attribute_value_2 = self.env['product.attribute.value'].create({
|
||||
'name': 'Aluminium',
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'sequence': 2,
|
||||
})
|
||||
product_attribute_2 = self.env['product.attribute'].create({
|
||||
'name': 'Color',
|
||||
'sequence': 20,
|
||||
})
|
||||
product_attribute_value_3 = self.env['product.attribute.value'].create({
|
||||
'name': 'White',
|
||||
'attribute_id': product_attribute_2.id,
|
||||
'sequence': 1,
|
||||
})
|
||||
product_attribute_value_4 = self.env['product.attribute.value'].create({
|
||||
'name': 'Black',
|
||||
'attribute_id': product_attribute_2.id,
|
||||
'sequence': 2,
|
||||
})
|
||||
|
||||
# Create product template
|
||||
self.product_product_4_product_template = self.env['product.template'].create({
|
||||
'name': 'Customizable Desk (TEST)',
|
||||
'standard_price': 500.0,
|
||||
'list_price': 750.0,
|
||||
})
|
||||
|
||||
# Generate variants
|
||||
self.env['product.template.attribute.line'].create([{
|
||||
'product_tmpl_id': self.product_product_4_product_template.id,
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'value_ids': [(4, product_attribute_value_1.id), (4, product_attribute_value_2.id)],
|
||||
}, {
|
||||
'product_tmpl_id': self.product_product_4_product_template.id,
|
||||
'attribute_id': product_attribute_2.id,
|
||||
'value_ids': [(4, product_attribute_value_3.id), (4, product_attribute_value_4.id)],
|
||||
|
||||
}])
|
||||
product_template = self.product_product_4_product_template
|
||||
|
||||
# Add Custom Attribute
|
||||
product_attribute_value_7 = self.env['product.attribute.value'].create({
|
||||
'name': 'Custom TEST',
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'sequence': 3,
|
||||
'is_custom': True
|
||||
})
|
||||
self.product_product_4_product_template.attribute_line_ids[0].write({'value_ids': [(4, product_attribute_value_7.id)]})
|
||||
|
||||
img_path = get_module_resource('product', 'static', 'img', 'product_product_11-image.png')
|
||||
img_content = base64.b64encode(open(img_path, "rb").read())
|
||||
self.product_product_11_product_template = self.env['product.template'].create({
|
||||
'name': 'Conference Chair (TEST)',
|
||||
'website_sequence': 9999, # laule
|
||||
'image_1920': img_content,
|
||||
'list_price': 16.50,
|
||||
})
|
||||
|
||||
self.env['product.template.attribute.line'].create({
|
||||
'product_tmpl_id': self.product_product_11_product_template.id,
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'value_ids': [(4, product_attribute_value_1.id), (4, product_attribute_value_2.id)],
|
||||
})
|
||||
self.product_product_11_product_template.attribute_line_ids[0].product_template_value_ids[1].price_extra = 6.40
|
||||
self.product_product_4_product_template.optional_product_ids = [(4, self.product_product_11_product_template.id)]
|
||||
|
||||
# Setup a second optional product
|
||||
self.product_product_1_product_template = self.env['product.template'].create({
|
||||
'name': 'Chair floor protection',
|
||||
'list_price': 12.0,
|
||||
})
|
||||
self.product_product_11_product_template.optional_product_ids = [(4, self.product_product_1_product_template.id)]
|
||||
|
||||
# fix runbot, sometimes one pricelist is chosen, sometimes the other...
|
||||
pricelists = self.env['website'].get_current_website().get_current_pricelist() | self.env.ref('product.list0')
|
||||
@@ -208,4 +304,5 @@ class TestUi(odoo.tests.HttpCase):
|
||||
self.start_tour("/", 'tour_shop_no_variant_attribute', login="demo")
|
||||
|
||||
def test_06_admin_list_view_b2c(self):
|
||||
self.env.ref('product.group_product_variant').write({'users': [(4, self.env.ref('base.user_admin').id)]})
|
||||
self.start_tour("/", 'shop_list_view_b2c', login="admin")
|
||||
|
||||
@@ -4,12 +4,67 @@
|
||||
import odoo.tests
|
||||
|
||||
from odoo import api
|
||||
from odoo.addons.base.tests.common import HttpCaseWithUserDemo, TransactionCaseWithUserDemo
|
||||
from odoo.addons.website_sale.controllers.main import WebsiteSale
|
||||
from odoo.addons.website.tools import MockRequest
|
||||
|
||||
|
||||
@odoo.tests.tagged('post_install', '-at_install')
|
||||
class TestUi(odoo.tests.HttpCase):
|
||||
class TestUi(HttpCaseWithUserDemo):
|
||||
|
||||
def setUp(self):
|
||||
super(TestUi, self).setUp()
|
||||
product_product_7 = self.env['product.product'].create({
|
||||
'name': 'Storage Box',
|
||||
'standard_price': 70.0,
|
||||
'list_price': 79.0,
|
||||
'website_published': True,
|
||||
})
|
||||
self.product_attribute_1 = self.env['product.attribute'].create({
|
||||
'name': 'Legs',
|
||||
'sequence': 10,
|
||||
})
|
||||
product_attribute_value_1 = self.env['product.attribute.value'].create({
|
||||
'name': 'Steel',
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'sequence': 1,
|
||||
})
|
||||
product_attribute_value_2 = self.env['product.attribute.value'].create({
|
||||
'name': 'Aluminium',
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'sequence': 2,
|
||||
})
|
||||
self.product_product_11_product_template = self.env['product.template'].create({
|
||||
'name': 'Conference Chair (CONFIG)',
|
||||
'list_price': 16.50,
|
||||
'accessory_product_ids': [(4, product_product_7.id)],
|
||||
})
|
||||
self.env['product.template.attribute.line'].create({
|
||||
'product_tmpl_id': self.product_product_11_product_template.id,
|
||||
'attribute_id': self.product_attribute_1.id,
|
||||
'value_ids': [(4, product_attribute_value_1.id), (4, product_attribute_value_2.id)],
|
||||
})
|
||||
|
||||
self.product_product_1_product_template = self.env['product.template'].create({
|
||||
'name': 'Chair floor protection',
|
||||
'list_price': 12.0,
|
||||
})
|
||||
self.product_product_11_product_template.optional_product_ids = [(6, 0, [self.product_product_1_product_template.id])]
|
||||
|
||||
cash_journal = self.env['account.journal'].create({'name': 'Cash - Test', 'type': 'cash', 'code': 'CASH - Test'})
|
||||
self.env.ref('payment.payment_acquirer_transfer').journal_id = cash_journal
|
||||
|
||||
# Avoid Shipping/Billing address page
|
||||
(self.env.ref('base.partner_admin') + self.partner_demo).write({
|
||||
'street': '215 Vine St',
|
||||
'city': 'Scranton',
|
||||
'zip': '18503',
|
||||
'country_id': self.env.ref('base.us').id,
|
||||
'state_id': self.env.ref('base.state_us_39').id,
|
||||
'phone': '+1 555-555-5555',
|
||||
'email': 'admin@yourcompany.example.com',
|
||||
})
|
||||
|
||||
def test_01_admin_shop_tour(self):
|
||||
self.start_tour("/", 'shop', login="admin")
|
||||
|
||||
@@ -28,7 +83,15 @@ class TestUi(odoo.tests.HttpCase):
|
||||
'tax_group_id': tax_group.id
|
||||
})
|
||||
# storage box
|
||||
self.env.ref('product.product_product_7').taxes_id = [tax.id]
|
||||
self.product_product_7 = self.env['product.product'].create({
|
||||
'name': 'Storage Box Test',
|
||||
'standard_price': 70.0,
|
||||
'list_price': 79.0,
|
||||
'categ_id': self.env.ref('product.product_category_all').id,
|
||||
'website_published': True,
|
||||
'invoice_policy': 'delivery',
|
||||
})
|
||||
self.product_product_7.taxes_id = [tax.id]
|
||||
self.env['res.config.settings'].create({
|
||||
'auth_signup_uninvited': 'b2c',
|
||||
'show_line_subtotals_tax_selection': 'tax_excluded',
|
||||
@@ -40,13 +103,14 @@ class TestUi(odoo.tests.HttpCase):
|
||||
|
||||
|
||||
@odoo.tests.tagged('post_install', '-at_install')
|
||||
class TestWebsiteSaleCheckoutAddress(odoo.tests.TransactionCase):
|
||||
class TestWebsiteSaleCheckoutAddress(TransactionCaseWithUserDemo):
|
||||
''' The goal of this method class is to test the address management on
|
||||
the checkout (new/edit billing/shipping, company_id, website_id..).
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
super(TestWebsiteSaleCheckoutAddress, self).setUp()
|
||||
self.website = self.env['website'].browse(1)
|
||||
self.website = self.env.ref('website.default_website')
|
||||
self.country_id = self.env['res.country'].search([], limit=1).id
|
||||
self.WebsiteSaleController = WebsiteSale()
|
||||
self.default_address_values = {
|
||||
@@ -101,7 +165,7 @@ class TestWebsiteSaleCheckoutAddress(odoo.tests.TransactionCase):
|
||||
self.website.company_id = self.company_b
|
||||
self.env.user.company_id = self.company_a
|
||||
|
||||
self.demo_user = self.env.ref('base.user_demo')
|
||||
self.demo_user = self.user_demo
|
||||
self.demo_user.company_ids += self.company_c
|
||||
self.demo_user.company_id = self.company_c
|
||||
self.demo_partner = self.demo_user.partner_id
|
||||
|
||||
@@ -3,13 +3,19 @@
|
||||
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import HttpCase, TransactionCase
|
||||
|
||||
from odoo.addons.base.tests.common import HttpCaseWithUserPortal
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestWebsiteSaleCartRecovery(HttpCase):
|
||||
class TestWebsiteSaleCartRecovery(HttpCaseWithUserPortal):
|
||||
|
||||
def test_01_shop_cart_recovery_tour(self):
|
||||
"""The goal of this test is to make sure cart recovery works."""
|
||||
self.env['product.product'].create({
|
||||
'name': 'Acoustic Bloc Screens',
|
||||
'list_price': 2950.0,
|
||||
'website_published': True,
|
||||
})
|
||||
|
||||
self.start_tour("/", 'shop_cart_recovery', login="portal")
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,16 @@ class TestWebsiteSaleMail(HttpCase):
|
||||
def test_01_shop_mail_tour(self):
|
||||
"""The goal of this test is to make sure sending SO by email works."""
|
||||
|
||||
self.env['product.product'].create({
|
||||
'name': 'Acoustic Bloc Screens',
|
||||
'list_price': 2950.0,
|
||||
'website_published': True,
|
||||
})
|
||||
self.env['res.partner'].create({
|
||||
'name': 'Azure Interior',
|
||||
'email': 'azure.Interior24@example.com',
|
||||
})
|
||||
|
||||
# we override unlink because we don't want the email to be auto deleted
|
||||
MailMail = odoo.addons.mail.models.mail_mail.MailMail
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ try:
|
||||
from unittest.mock import patch
|
||||
except ImportError:
|
||||
from mock import patch
|
||||
from odoo.addons.base.tests.common import TransactionCaseWithUserDemo, HttpCaseWithUserPortal
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import HttpCase, TransactionCase
|
||||
from odoo.tools import DotDict
|
||||
@@ -37,15 +38,58 @@ class TestWebsitePriceList(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestWebsitePriceList, self).setUp()
|
||||
self.env.user.partner_id.country_id = False # Remove country to avoid property pricelist computed.
|
||||
self.website = self.env['website'].browse(1)
|
||||
self.website = self.env.ref('website.default_website')
|
||||
self.website.user_id = self.env.user
|
||||
|
||||
self.env['product.pricelist'].search([]).write({'website_id': False})
|
||||
website_pls = ('list_benelux', 'list_christmas', 'list_europe')
|
||||
for pl in website_pls:
|
||||
self.env.ref('website_sale.' + pl).website_id = self.website.id
|
||||
(self.env['product.pricelist'].search([]) - self.env.ref('product.list0')).write({'website_id': False, 'active': False})
|
||||
self.benelux = self.env['res.country.group'].create({
|
||||
'name': 'BeNeLux',
|
||||
'country_ids': [(6, 0, (self.env.ref('base.be') + self.env.ref('base.lu') + self.env.ref('base.nl')).ids)]
|
||||
})
|
||||
self.list_benelux = self.env['product.pricelist'].create({
|
||||
'name': 'Benelux',
|
||||
'selectable': True,
|
||||
'website_id': self.website.id,
|
||||
'country_group_ids': [(4, self.benelux.id)],
|
||||
'sequence': 2,
|
||||
})
|
||||
item_benelux = self.env['product.pricelist.item'].create({
|
||||
'pricelist_id': self.list_benelux.id,
|
||||
'compute_price': 'percentage',
|
||||
'base': 'list_price',
|
||||
'percent_price': 10,
|
||||
'currency_id': self.env.ref('base.EUR').id,
|
||||
})
|
||||
|
||||
|
||||
self.list_christmas = self.env['product.pricelist'].create({
|
||||
'name': 'Christmas',
|
||||
'selectable': False,
|
||||
'website_id': self.website.id,
|
||||
'country_group_ids': [(4, self.env.ref('base.europe').id)],
|
||||
'sequence': 20,
|
||||
})
|
||||
item_christmas = self.env['product.pricelist.item'].create({
|
||||
'pricelist_id': self.list_christmas.id,
|
||||
'compute_price': 'formula',
|
||||
'base': 'list_price',
|
||||
'price_discount': 20,
|
||||
})
|
||||
|
||||
list_europe = self.env['product.pricelist'].create({
|
||||
'name': 'EUR',
|
||||
'selectable': True,
|
||||
'website_id': self.website.id,
|
||||
'country_group_ids': [(4, self.env.ref('base.europe').id)],
|
||||
'sequence': 3,
|
||||
'currency_id': self.env.ref('base.EUR').id,
|
||||
})
|
||||
item_europe = self.env['product.pricelist.item'].create({
|
||||
'pricelist_id': list_europe.id,
|
||||
'compute_price': 'formula',
|
||||
'base': 'list_price',
|
||||
})
|
||||
self.env.ref('product.list0').website_id = self.website.id
|
||||
self.env.ref('website_sale.list_benelux').selectable = True
|
||||
self.website.pricelist_id = self.ref('product.list0')
|
||||
|
||||
ca_group = self.env['res.country.group'].create({
|
||||
@@ -112,7 +156,7 @@ class TestWebsitePriceList(TransactionCase):
|
||||
% (country, len(pls), pls.mapped('name'), len(result), result))
|
||||
|
||||
def test_get_pricelist_available_promocode(self):
|
||||
christmas_pl = self.ref('website_sale.list_christmas')
|
||||
christmas_pl = self.list_christmas.id
|
||||
|
||||
country_list = {
|
||||
False: True,
|
||||
@@ -265,7 +309,11 @@ class TestWebsitePriceListAvailableGeoIP(TestWebsitePriceListAvailable):
|
||||
|
||||
# set different country groups on pricelists
|
||||
c_EUR = self.env.ref('base.europe')
|
||||
c_BENELUX = self.env.ref('website_sale.benelux')
|
||||
c_BENELUX = self.env['res.country.group'].create({
|
||||
'name': 'BeNeLux',
|
||||
'country_ids': [(6, 0, (self.env.ref('base.be') + self.env.ref('base.lu') + self.env.ref('base.nl')).ids)]
|
||||
})
|
||||
|
||||
self.BE = self.env.ref('base.be')
|
||||
NL = self.env.ref('base.nl')
|
||||
c_BE = self.env['res.country.group'].create({'name': 'Belgium', 'country_ids': [(6, 0, [self.BE.id])]})
|
||||
@@ -324,7 +372,7 @@ class TestWebsitePriceListAvailableGeoIP(TestWebsitePriceListAvailable):
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestWebsitePriceListHttp(HttpCase):
|
||||
class TestWebsitePriceListHttp(HttpCaseWithUserPortal):
|
||||
def test_get_pricelist_available_multi_company(self):
|
||||
''' Test that the `property_product_pricelist` of `res.partner` is not
|
||||
computed as SUPERUSER_ID.
|
||||
@@ -348,7 +396,7 @@ class TestWebsitePriceListHttp(HttpCase):
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestWebsitePriceListMultiCompany(TransactionCase):
|
||||
class TestWebsitePriceListMultiCompany(TransactionCaseWithUserDemo):
|
||||
def setUp(self):
|
||||
''' Create a basic multi-company pricelist environment:
|
||||
- Set up 2 companies with their own company-restricted pricelist each.
|
||||
@@ -359,14 +407,14 @@ class TestWebsitePriceListMultiCompany(TransactionCase):
|
||||
'''
|
||||
super(TestWebsitePriceListMultiCompany, self).setUp()
|
||||
|
||||
self.demo_user = self.env.ref('base.user_demo')
|
||||
self.demo_user = self.user_demo
|
||||
|
||||
# Create and add demo user to 2 companies
|
||||
self.company1 = self.demo_user.company_id
|
||||
self.company2 = self.env['res.company'].create({'name': 'Test Company'})
|
||||
self.demo_user.company_ids += self.company2
|
||||
# Set company2 as current company for demo user
|
||||
self.website = self.env['website'].browse(1)
|
||||
self.website = self.env.ref('website.default_website')
|
||||
self.website.company_id = self.company2
|
||||
|
||||
# Create a company pricelist for each company and set it to demo user
|
||||
@@ -431,4 +479,4 @@ class TestWebsitePriceListMultiCompany(TransactionCase):
|
||||
# Indeed, the ir.rule for pricelists rights about company should allow to
|
||||
# also read a pricelist from another company if that company is the one
|
||||
# from the currently visited website.
|
||||
self.env(user=self.env.ref('base.user_demo'))['product.pricelist'].browse(demo_pl.id).name
|
||||
self.env(user=self.user_demo)['product.pricelist'].browse(demo_pl.id).name
|
||||
|
||||
@@ -8,7 +8,7 @@ class WebsiteSaleVisitorTests(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.website = self.env['website'].browse(1)
|
||||
self.website = self.env.ref('website.default_website')
|
||||
self.WebsiteSaleController = WebsiteSale()
|
||||
self.cookies = {}
|
||||
|
||||
@@ -20,7 +20,10 @@ class WebsiteSaleVisitorTests(TransactionCase):
|
||||
self.assertEqual(len(Visitor.search([])), 0, "No visitor at the moment")
|
||||
self.assertEqual(len(Track.search([])), 0, "No track at the moment")
|
||||
|
||||
product = self.env.ref('product.product_product_7')
|
||||
product = self.env['product.product'].create({
|
||||
'name': 'Storage Box',
|
||||
'website_published': True,
|
||||
})
|
||||
|
||||
with MockRequest(self.env, website=self.website):
|
||||
self.cookies = self.WebsiteSaleController.products_recently_viewed_update(product.id)
|
||||
@@ -34,7 +37,12 @@ class WebsiteSaleVisitorTests(TransactionCase):
|
||||
self.assertEqual(len(Visitor.search([])), 1, "No visitor should be created after visiting another tracked product")
|
||||
self.assertEqual(len(Track.search([])), 1, "No track should be created after visiting the same tracked product before 30 min")
|
||||
|
||||
product = self.env.ref('product.product_product_6')
|
||||
product = self.env['product.product'].create({
|
||||
'name': 'Large Cabinet',
|
||||
'website_published': True,
|
||||
'list_price': 320.0,
|
||||
})
|
||||
|
||||
with MockRequest(self.env, website=self.website, cookies=self.cookies):
|
||||
self.WebsiteSaleController.products_recently_viewed_update(product.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user