diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml
index 9591fab952f..9adcef8dd5b 100644
--- a/addons/sale/data/mail_template_data.xml
+++ b/addons/sale/data/mail_template_data.xml
@@ -85,7 +85,7 @@
Quantity |
-
+
VAT Excl.
@@ -123,7 +123,7 @@
| Taking care of Trees Course |
1 |
-
+
$ 10.00
diff --git a/addons/website_event_booth_sale/tests/test_event_booth_sale.py b/addons/website_event_booth_sale/tests/test_event_booth_sale.py
index b539c9e6d45..9499d602db0 100644
--- a/addons/website_event_booth_sale/tests/test_event_booth_sale.py
+++ b/addons/website_event_booth_sale/tests/test_event_booth_sale.py
@@ -13,47 +13,48 @@ from odoo.tests.common import tagged
@tagged('post_install', '-at_install')
class TestWebsiteEventBoothSale(HttpCase, TestWebsiteEventSaleCommon):
- def setUp(self):
- super().setUp()
- self.env["res.company"].sudo().search([]).show_line_subtotals_tax_selection = 'tax_included'
- self.tax = self.env['account.tax'].sudo().create({
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.env['website'].sudo().search([]).show_line_subtotals_tax_selection = 'tax_included'
+ cls.tax = cls.env['account.tax'].sudo().create({
'name': 'Tax 10',
'amount': 10,
})
- self.booth_product = self.env['product.product'].create({
+ cls.booth_product = cls.env['product.product'].create({
'name': 'Test Booth Product',
'description_sale': 'Mighty Booth Description',
'list_price': 20,
'standard_price': 60.0,
- 'taxes_id': [(6, 0, [self.tax.id])],
+ 'taxes_id': [(6, 0, [cls.tax.id])],
'detailed_type': 'event_booth',
})
- self.event_booth_category = self.env['event.booth.category'].create({
+ cls.event_booth_category = cls.env['event.booth.category'].create({
'name': 'Standard',
'description': ' Standard ',
- 'product_id': self.booth_product.id,
+ 'product_id': cls.booth_product.id,
'price': 100.0,
})
- self.event_type = self.env['event.type'].create({
+ cls.event_type = cls.env['event.type'].create({
'name': 'Booth Type',
'event_type_booth_ids': [
Command.create({
'name': 'Standard 1',
- 'booth_category_id': self.event_booth_category.id,
+ 'booth_category_id': cls.event_booth_category.id,
}),
Command.create({
'name': 'Standard 2',
- 'booth_category_id': self.event_booth_category.id,
+ 'booth_category_id': cls.event_booth_category.id,
}),
Command.create({
'name': 'Standard 3',
- 'booth_category_id': self.event_booth_category.id,
+ 'booth_category_id': cls.event_booth_category.id,
}),
],
})
- self.env['event.event'].create({
+ cls.env['event.event'].create({
'name': 'Test Event Booths',
- 'event_type_id': self.event_type.id,
+ 'event_type_id': cls.event_type.id,
'date_begin': fields.Datetime.to_string(datetime.today() + timedelta(days=1)),
'date_end': fields.Datetime.to_string(datetime.today() + timedelta(days=15)),
'website_published': True,
diff --git a/addons/website_event_booth_sale/views/event_booth_templates.xml b/addons/website_event_booth_sale/views/event_booth_templates.xml
index e5ccd311c55..1435d56a445 100644
--- a/addons/website_event_booth_sale/views/event_booth_templates.xml
+++ b/addons/website_event_booth_sale/views/event_booth_templates.xml
@@ -1,34 +1,33 @@
-
+
-
-
+
-
+
-
+ t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"/>
-
-
+
+
Free
event.company_id.sudo().currency_id._convert(
- booth_category.price_reduce_taxinc if env.company.show_line_subtotals_tax_selection == 'tax_included' else booth_category.price_reduce,
- website.get_current_pricelist().currency_id,
+ booth_category.price_reduce_taxinc if website.show_line_subtotals_tax_selection == 'tax_included' else booth_category.price_reduce,
+ website.currency_id,
event.company_id,
datetime.date.today()
) or '0'
@@ -47,4 +46,4 @@
-
+
diff --git a/addons/website_event_sale/views/website_event_templates.xml b/addons/website_event_sale/views/website_event_templates.xml
index 03736de633f..9100aa9136f 100644
--- a/addons/website_event_sale/views/website_event_templates.xml
+++ b/addons/website_event_sale/views/website_event_templates.xml
@@ -15,22 +15,22 @@
-
-
+
-
+
+ t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"/>
-
-
+
+
@@ -55,22 +55,22 @@
-
-
+
-
+
+ t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"/>
-
-
+
+
diff --git a/addons/website_sale/controllers/delivery.py b/addons/website_sale/controllers/delivery.py
index f3f76d3ff9a..083b5c71d90 100644
--- a/addons/website_sale/controllers/delivery.py
+++ b/addons/website_sale/controllers/delivery.py
@@ -181,7 +181,7 @@ class WebsiteSaleDelivery(WebsiteSale):
product=carrier.product_id,
partner=order.partner_shipping_id,
)
- if not is_express_checkout_flow and request.env.company.show_line_subtotals_tax_selection == 'tax_excluded':
+ if not is_express_checkout_flow and request.website.show_line_subtotals_tax_selection == 'tax_excluded':
rate['price'] = taxes['total_excluded']
else:
rate['price'] = taxes['total_included']
diff --git a/addons/website_sale/models/product_product.py b/addons/website_sale/models/product_product.py
index ebd5c9719c8..969888268ce 100644
--- a/addons/website_sale/models/product_product.py
+++ b/addons/website_sale/models/product_product.py
@@ -99,7 +99,8 @@ class Product(models.Model):
def _get_contextual_price_tax_selection(self):
self.ensure_one()
price = self._get_contextual_price()
- line_tax_type = self.env.company.show_line_subtotals_tax_selection
+ website = self.env['website'].get_current_website()
+ line_tax_type = website.show_line_subtotals_tax_selection
company_taxes = self.taxes_id.filtered(lambda tax: tax.company_id == self.env.company)
if line_tax_type == "tax_included" and company_taxes:
price = company_taxes.compute_all(price, product=self, partner=self.env['res.partner'])['total_included']
diff --git a/addons/website_sale/models/product_template.py b/addons/website_sale/models/product_template.py
index 9b742c29363..fb218128467 100644
--- a/addons/website_sale/models/product_template.py
+++ b/addons/website_sale/models/product_template.py
@@ -178,6 +178,11 @@ class ProductTemplate(models.Model):
show_discount = pricelist and pricelist.discount_policy == 'without_discount'
base_sales_prices = self._price_compute('list_price', currency=currency)
+ website = self.env['website'].get_current_website()
+ if website.show_line_subtotals_tax_selection == 'tax_excluded':
+ tax_display = 'total_excluded'
+ else:
+ tax_display = 'total_included'
res = {}
for template in self:
@@ -185,7 +190,6 @@ class ProductTemplate(models.Model):
product_taxes = template.sudo().taxes_id.filtered(lambda t: t.company_id == t.env.company)
taxes = fiscal_position.map_tax(product_taxes)
- tax_display = 'total_excluded' if self.env.company.show_line_subtotals_tax_selection == 'tax_excluded' else 'total_included'
template_price_vals = {
'price_reduce': price_reduce
@@ -312,10 +316,11 @@ class ProductTemplate(models.Model):
def _price_with_tax_computed(
self, price, product_taxes, taxes, company_id, currency, product, partner
):
+ website = self.env['website'].get_current_website()
price = self.env['account.tax']._fix_tax_included_price_company(
price, product_taxes, taxes, company_id
)
- show_tax = self.env.company.show_line_subtotals_tax_selection
+ show_tax = website.show_line_subtotals_tax_selection
tax_display = 'total_excluded' if show_tax == 'tax_excluded' else 'total_included'
# The list_price is always the price of one.
return taxes.compute_all(price, currency, 1, product, partner)[tax_display]
diff --git a/addons/website_sale/models/res_company.py b/addons/website_sale/models/res_company.py
index c65d4af64aa..cc9df3497d6 100644
--- a/addons/website_sale/models/res_company.py
+++ b/addons/website_sale/models/res_company.py
@@ -7,11 +7,6 @@ from odoo import api, fields, models
class ResCompany(models.Model):
_inherit = 'res.company'
- show_line_subtotals_tax_selection = fields.Selection([
- ('tax_excluded', 'Tax Excluded'),
- ('tax_included', 'Tax Included')], string="Line Subtotals Tax Display",
- required=True, default='tax_excluded',
- )
website_sale_onboarding_payment_provider_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done")], string="State of the website sale onboarding payment provider step", default='not_done')
@api.model
diff --git a/addons/website_sale/models/res_config_settings.py b/addons/website_sale/models/res_config_settings.py
index 155d270e631..282a9072a22 100644
--- a/addons/website_sale/models/res_config_settings.py
+++ b/addons/website_sale/models/res_config_settings.py
@@ -52,9 +52,8 @@ class ResConfigSettings(models.TransientModel):
website_sale_contact_us_button_url = fields.Char(string="Button URL", related='website_id.contact_us_button_url', readonly=False)
website_sale_enabled_portal_reorder_button = fields.Boolean(string="Re-order From Portal", related='website_id.enabled_portal_reorder_button', readonly=False)
show_line_subtotals_tax_selection = fields.Selection(
- required=True,
readonly=False,
- related="company_id.show_line_subtotals_tax_selection",
+ related='website_id.show_line_subtotals_tax_selection',
)
@api.depends('website_id')
diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index eacbabec3a9..7c9cf9db4d6 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -30,9 +30,7 @@ class SaleOrder(models.Model):
amount_delivery = fields.Monetary(
string="Delivery Amount",
compute='_compute_amount_delivery',
- help="The amount without tax.",
- store=True,
- tracking=True,
+ help="Tax included or excluded depending on the website configuration.",
)
access_point_address = fields.Json("Delivery Point Address")
@@ -79,13 +77,15 @@ class SaleOrder(models.Model):
order.cart_quantity = int(sum(order.mapped('website_order_line.product_uom_qty')))
order.only_services = all(l.product_id.type == 'service' for l in order.website_order_line)
- @api.depends('order_line.price_unit', 'order_line.tax_id', 'order_line.discount', 'order_line.product_uom_qty')
+ @api.depends('order_line.price_total', 'order_line.price_subtotal')
def _compute_amount_delivery(self):
- for order in self:
- if self.env.company.show_line_subtotals_tax_selection == 'tax_excluded':
- order.amount_delivery = sum(order.order_line.filtered('is_delivery').mapped('price_subtotal'))
+ self.amount_delivery = 0.0
+ for order in self.filtered('website_id'):
+ delivery_lines = order.order_line.filtered('is_delivery')
+ if order.website_id.show_line_subtotals_tax_selection == 'tax_excluded':
+ order.amount_delivery = sum(delivery_lines.mapped('price_subtotal'))
else:
- order.amount_delivery = sum(order.order_line.filtered('is_delivery').mapped('price_total'))
+ order.amount_delivery = sum(delivery_lines.mapped('price_total'))
@api.depends('website_id', 'date_order', 'order_line', 'state', 'partner_id')
def _compute_abandoned_cart(self):
diff --git a/addons/website_sale/models/website.py b/addons/website_sale/models/website.py
index 284fb57849d..910abb480a4 100644
--- a/addons/website_sale/models/website.py
+++ b/addons/website_sale/models/website.py
@@ -26,6 +26,14 @@ class Website(models.Model):
salesteam_id = fields.Many2one('crm.team',
string='Sales Team', ondelete="set null",
default=_default_salesteam_id)
+ show_line_subtotals_tax_selection = fields.Selection(
+ selection=[
+ ('tax_excluded', "Tax Excluded"),
+ ('tax_included', "Tax Included"),
+ ],
+ string="Line Subtotals Tax Display",
+ required=True, default='tax_excluded',
+ )
pricelist_id = fields.Many2one(
'product.pricelist', compute='_compute_pricelist_id', string="Default Pricelist if any")
diff --git a/addons/website_sale/tests/__init__.py b/addons/website_sale/tests/__init__.py
index 7aee0e333e9..d5671ee7747 100644
--- a/addons/website_sale/tests/__init__.py
+++ b/addons/website_sale/tests/__init__.py
@@ -24,6 +24,5 @@ from . import test_website_sale_visitor
from . import test_website_sale_product
from . import test_website_sale_shop_variant_exclusion
from . import test_website_editor
-from . import test_setting
from . import test_website_sale_reorder_from_portal
from . import test_website_sale_snippets
diff --git a/addons/website_sale/tests/test_setting.py b/addons/website_sale/tests/test_setting.py
deleted file mode 100644
index 6fb1d58806e..00000000000
--- a/addons/website_sale/tests/test_setting.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-from odoo.addons.account.tests.common import AccountTestInvoicingCommon
-from odoo.tests import tagged
-
-
-@tagged('post_install', '-at_install')
-class TestSettings(AccountTestInvoicingCommon):
-
- def test_switch_taxB2B_taxB2C(self):
- """
- Since having users both in the tax B2B and tax B2C groups raise,
- modifications of the settings must be done in the right order;
- otherwise it is impossible to change the settings.
- """
- # at each setting change, all users should be removed from one group and added to the other
- # so picking an arbitrary witness should be equivalent to checking that everything worked.
- config = self.env['res.config.settings'].create({})
- config.show_line_subtotals_tax_selection = "tax_included"
- self.assertEqual(self.env.user.company_id.show_line_subtotals_tax_selection, "tax_included")
-
-
- def test_switch_taxB2B_taxB2C_multicompany(self):
- """
- Contrarily to the (apparently reasonable) assumption that adding users
- to group and removing them was symmetrical, it may not be the case
- if one is done in SQL and the other via the ORM.
- Because the latter automatically takes into account record rules that
- might make some users invisible.
- This one is identical to the previous, except that we do the actions
- with a non-superuser user, and in a new company with one user in common
- with another company which has a different taxB2X setting.
- """
-
- Settings = self.env['res.config.settings'].with_user(self.env.user.id)
- config = Settings.create({})
- config.show_line_subtotals_tax_selection = "tax_included"
- self.assertEqual(self.env.user.company_id.show_line_subtotals_tax_selection, "tax_included")
-
- self.env.user.company_id = self.company_data_2["company"].id
- self.assertEqual(self.env.user.company_id.show_line_subtotals_tax_selection, "tax_excluded")
diff --git a/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py b/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py
index 57d8ff8c032..3644d6710ff 100644
--- a/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py
+++ b/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py
@@ -58,7 +58,7 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes
self.assertEqual(combination_info['has_discounted_price'], False)
# CASE: B2C setting
- self.env.company.show_line_subtotals_tax_selection = 'tax_included'
+ website.show_line_subtotals_tax_selection = 'tax_included'
combination_info = product_template._get_combination_info(pricelist=pricelist)
self.assertEqual(combination_info['price'], 2222 * discount_rate * currency_ratio * tax_ratio)
@@ -116,7 +116,7 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes
computer_ssd_attribute_lines.product_template_value_ids[0].price_extra = 200
# Enable tax included
- self.env.company.show_line_subtotals_tax_selection = 'tax_included'
+ website.show_line_subtotals_tax_selection = 'tax_included'
combination_info = product._get_combination_info(pricelist=pricelist)
self.assertEqual(combination_info['price'], 575, "500$ + 15% tax")
diff --git a/addons/website_sale/views/res_config_settings_views.xml b/addons/website_sale/views/res_config_settings_views.xml
index d7f51e72aac..3f5a24a8ad2 100644
--- a/addons/website_sale/views/res_config_settings_views.xml
+++ b/addons/website_sale/views/res_config_settings_views.xml
@@ -73,9 +73,14 @@
-
+
+
+
+
+ Prices displayed on your eCommerce
+
-
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index 0746a245eaa..01fa2c5a5b3 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -1141,10 +1141,10 @@
-
+
VAT Excluded
-
+
VAT Included
@@ -1454,12 +1454,12 @@
-
-
-
-
-
-
+
+
@@ -2121,8 +2121,12 @@
|
-
-
+
+
|
|