[FIX] website_sale: do not show unavailable carriers
Carriers with no/invalid/incompatible rules shouldn't be displayed in the checkout process. Cherry-picked from https://github.com/odoo/odoo/commit/5052b9e4a15155c694cf005fdf330997770c6cac and added tests. task-3284612 opw-3413820 closes odoo/odoo#147004 X-original-commit: 0491ac9a8d4dbce9e67d336d149b210a558a945c Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: Vallaeys Valentin (vava) <vava@odoo.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from unittest.mock import patch
|
||||
@@ -12,6 +11,7 @@ from odoo.addons.sale.tests.common import SaleCommon
|
||||
from odoo.addons.website_sale.controllers.delivery import WebsiteSaleDelivery
|
||||
from odoo.addons.website.tools import MockRequest
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestWebsiteSaleDeliveryController(PaymentCommon, SaleCommon):
|
||||
def setUp(self):
|
||||
@@ -73,7 +73,6 @@ class TestWebsiteSaleDeliveryController(PaymentCommon, SaleCommon):
|
||||
self.env['delivery.carrier'].create([
|
||||
{
|
||||
'name': 'Over 300',
|
||||
'fixed_price': 20.0,
|
||||
'delivery_type': 'base_on_rule',
|
||||
'product_id': self.product_delivery_poste.id,
|
||||
'website_published': True,
|
||||
@@ -82,16 +81,32 @@ class TestWebsiteSaleDeliveryController(PaymentCommon, SaleCommon):
|
||||
'operator': '>=',
|
||||
'max_value': 300,
|
||||
'variable': 'price',
|
||||
'list_base_price': 0,
|
||||
})
|
||||
]
|
||||
}),
|
||||
],
|
||||
}, {
|
||||
'name': 'No rules',
|
||||
'fixed_price': 20.0,
|
||||
'name': 'Under 300',
|
||||
'delivery_type': 'base_on_rule',
|
||||
'product_id': self.product_delivery_poste.id,
|
||||
'website_published': True,
|
||||
}
|
||||
'price_rule_ids': [
|
||||
Command.create({
|
||||
'operator': '<',
|
||||
'max_value': 300,
|
||||
'variable': 'price',
|
||||
}),
|
||||
],
|
||||
}, {
|
||||
'name': 'No rules',
|
||||
'delivery_type': 'base_on_rule',
|
||||
'product_id': self.product_delivery_poste.id,
|
||||
'website_published': True,
|
||||
}, {
|
||||
'name': 'Fixed',
|
||||
'product_id': self.product_delivery_poste.id,
|
||||
'website_published': True,
|
||||
},
|
||||
])
|
||||
|
||||
self.assertFalse(self.empty_order._get_delivery_methods())
|
||||
self.assertEqual(
|
||||
self.empty_order._get_delivery_methods().mapped('name'), ['Under 300', 'Fixed']
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user