[FIX] website_sale_delivery: fix unstable tour

This PR adds some trigger to make sure that all python request
is correctly finished. This is needed because an unfinished python request
makes a traceback appears on runbot.

opw-28835921

closes odoo/odoo#99475

X-original-commit: 7a98b59b36e9e2cf1816b73ebc3be5de58e054c2
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
roen-odoo
2022-09-04 15:37:49 +02:00
committed by William Braeckman (wbr)
parent d4cc66793e
commit 14408d6af5
8 changed files with 33 additions and 13 deletions
+6
View File
@@ -79,6 +79,7 @@ class LoyaltyProgram(models.Model):
portal_point_name = fields.Char(default='Points', translate=True,
compute='_compute_portal_point_name', readonly=False, store=True)
is_nominative = fields.Boolean(compute='_compute_is_nominative')
is_payment_program = fields.Boolean(compute='_compute_is_payment_program')
# Technical field used for a label
available_on = fields.Boolean("Available On", store=False,
@@ -149,6 +150,11 @@ class LoyaltyProgram(models.Model):
program.is_nominative = program.applies_on == 'both' or\
(program.program_type == 'ewallet' and program.applies_on == 'future')
@api.depends('program_type')
def _compute_is_payment_program(self):
for program in self:
program.is_payment_program = program.program_type in ('gift_card', 'ewallet')
@api.model
def _program_items_name(self):
return {
+3 -2
View File
@@ -158,7 +158,8 @@ class SaleOrder(models.Model):
discountable = 0
discountable_per_tax = defaultdict(int)
for line in (self.order_line - self._get_no_effect_on_threshold_lines()):
lines = self.order_line if reward.program_id.is_payment_program else (self.order_line - self._get_no_effect_on_threshold_lines())
for line in lines:
# Ignore lines from this reward
if not line.product_uom_qty or not line.price_unit:
continue
@@ -709,7 +710,7 @@ class SaleOrder(models.Model):
not line.coupon_id:
continue
seen_rewards.add(line.reward_identifier_code)
if line.reward_id.program_id.program_type not in ('gift_card', 'ewallet'):
if line.reward_id.program_id.is_payment_program:
line_rewards.append((line.reward_id, line.coupon_id, line.reward_identifier_code, line.product_id))
else:
payment_rewards.append((line.reward_id, line.coupon_id, line.reward_identifier_code, line.product_id))
@@ -3,4 +3,3 @@
from . import test_ui
from . import test_controller
from . import test_website_sale_delivery
@@ -76,7 +76,8 @@ class SaleOrder(models.Model):
if len(coupon.program_id.reward_ids) != 1 or\
coupon.program_id.is_nominative or\
(rewards.reward_type == 'product' and rewards.multi_product) or\
rewards in self.disabled_auto_rewards:
rewards in self.disabled_auto_rewards or\
rewards in self.order_line.reward_id:
continue
try:
res = self._apply_program_reward(rewards, coupon)
@@ -10,7 +10,10 @@
'auto_install': True,
'assets': {
'web.assets_frontend': [
'website_sale_loyalty_delivery/static/**/*',
'website_sale_loyalty_delivery/static/src/**/*',
],
'web.assets_tests': [
'website_sale_loyalty_delivery/static/tests/**/*',
],
},
'license': 'LGPL-3',
@@ -1,11 +1,11 @@
odoo.define('website_sale_delivery.test', function (require) {
odoo.define('website_sale_loyalty_giftcard.test', function (require) {
'use strict';
require("website_sale.tour");
var tour = require("web_tour.tour");
const tourUtils = require('website_sale.tour_utils');
tour.register('shop_sale_giftcard_delivery', {
tour.register('shop_sale_loyalty_delivery', {
test: true,
url: '/shop?search=Accoustic',
},
@@ -30,7 +30,7 @@ odoo.define('website_sale_delivery.test', function (require) {
run: 'click'
},
{
content: "select free delivery method",
content: "select delivery method 1",
trigger: "li label:contains(delivery1)",
run: 'click'
},
@@ -41,8 +41,8 @@ odoo.define('website_sale_delivery.test', function (require) {
},
{
content: "Enter gift card code",
trigger: "input[name='promo']",
run: 'text 044c-7c9c-432f-810e-dcff'
trigger: "form[name='coupon_code'] input[name='promo']",
run: 'text 123456'
},
{
content: "click on 'Pay'",
@@ -52,6 +52,12 @@ odoo.define('website_sale_delivery.test', function (require) {
{
content: "check if delivery price is correct'",
trigger: "#order_delivery .oe_currency_value:contains(5.00)",
run: () => {} // this is a check
},
{
content: "check if total price is correct",
trigger: "tr#order_total span.oe_currency_value:contains(0.00)",
run: () => {} // this is a check
},
]
);
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_website_sale_loyalty_delivery
@@ -77,9 +77,9 @@ class TestWebsiteSaleDelivery(HttpCase):
})
def test_shop_sale_gift_card_keep_delivery(self):
#get admin user and set his preferred shipping method to normal delivery
# Get admin user and set his preferred shipping method to normal delivery
# This test also tests that we can indeed pay delivery fees with gift cards/ewallet
admin_user = self.env.ref('base.user_admin')
admin_user.partner_id.write({'property_delivery_carrier_id': self.normal_delivery.id})
self.start_tour("/", 'shop_sale_giftcard_delivery', login='admin')
self.start_tour("/", 'shop_sale_loyalty_delivery', login='admin')