mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 22:51:59 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="70" height="70" viewBox="0 0 70 70"><defs><path id="a" d="M4 0h61c4 0 5 1 5 5v60c0 4-1 5-5 5H4c-3 0-4-1-4-5V5c0-4 1-5 4-5z"/><linearGradient id="c" x1="100%" x2="0%" y1="0%" y2="100%"><stop offset="0%" stop-color="#7CC098"/><stop offset="100%" stop-color="#5F8A71"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><g mask="url(#b)"><path fill="url(#c)" d="M0 0H70V70H0z"/><path fill="#FFF" fill-opacity=".383" d="M4 1h61c2.667 0 4.333.667 5 2V0H0v3c.667-1.333 2-2 4-2z"/><path fill="#393939" d="M44.5 69H4c-2 0-4-1-4-4V36.525L21 16h9l4-4h3l4 5h9l4 11 1 26-10.5 15z" opacity=".324"/><path fill="#000" fill-opacity=".383" d="M4 69h61c2.667 0 4.333-1 5-3v4H0v-4c.667 2 2 3 4 3z"/><path fill="#000" d="M16 51.482V29.488L20.875 18h9.147a5.5 5.5 0 0 1 10.956 0h9.147L55 29.488V56H16v-4.023l15.79-5.185.216 1.967 1.37-.61.642-2.245 5.024-2.236.628 7.555 1.826-.813 1.656-8.572 5.023-2.237c.758-.337 1.126-1.157.824-1.836-.302-.678-1.158-.953-1.916-.616l-5.023 2.237-7.478-4.506-1.827.813 5.195 5.522-5.023 2.237-2.098-1.025-1.37.61 1.466 1.645L16 51.482zM30.207 20h-8.951L18 29h35l-4.07-9h-8.137a5.502 5.502 0 0 1-10.586 0zm3.934-.08H33a2.49 2.49 0 0 0 .165.99c.116.287.281.528.495.725.213.197.47.348.77.455.3.107.63.163.99.17v.78h.43v-.78c.333-.013.643-.068.93-.165a2.23 2.23 0 0 0 .75-.42 1.93 1.93 0 0 0 .505-.69c.123-.277.185-.602.185-.975 0-.36-.067-.663-.2-.91a1.904 1.904 0 0 0-.53-.62 2.957 2.957 0 0 0-.76-.41c-.287-.107-.58-.2-.88-.28v-2.11c.36 0 .621.09.785.27.163.18.251.44.265.78h1.14a1.99 1.99 0 0 0-.175-.86 1.721 1.721 0 0 0-.47-.61 1.996 1.996 0 0 0-.695-.36c-.267-.08-.55-.12-.85-.12V14h-.43v.78c-.3 0-.587.043-.86.13a2.302 2.302 0 0 0-.725.375c-.21.163-.377.367-.5.61a1.845 1.845 0 0 0-.185.845c0 .367.066.673.2.92.133.247.308.452.525.615.216.163.46.297.73.4.27.103.541.192.815.265v2.42c-.46-.013-.79-.147-.99-.4-.2-.253-.297-.6-.29-1.04zM35.13 16v2a3.704 3.704 0 0 1-.415-.125 1.33 1.33 0 0 1-.36-.195 1.013 1.013 0 0 1-.255-.29.795.795 0 0 1-.1-.41c0-.353.098-.605.295-.755.197-.15.475-.225.835-.225zm.87 5.33V19c.153.04.303.087.45.14.147.053.278.123.395.21.117.087.21.193.28.32a.96.96 0 0 1 .105.47c0 .4-.115.692-.345.875-.23.183-.525.288-.885.315z" opacity=".3"/><path fill="#FFF" d="M16 49.482V27.488L20.875 16h9.147a5.5 5.5 0 0 1 10.956 0h9.147L55 27.488V54H16v-4.023l15.79-5.185.216 1.967 1.37-.61.642-2.245 5.024-2.236.628 7.555 1.826-.813 1.656-8.572 5.023-2.237c.758-.337 1.126-1.157.824-1.836-.302-.678-1.158-.953-1.916-.616l-5.023 2.237-7.478-4.506-1.827.813 5.195 5.522-5.023 2.237-2.098-1.025-1.37.61 1.466 1.645L16 49.482zM30.207 18h-8.951L18 27h35l-4.07-9h-8.137a5.502 5.502 0 0 1-10.586 0zm3.934-.08H33a2.49 2.49 0 0 0 .165.99c.116.287.281.528.495.725.213.197.47.348.77.455.3.107.63.163.99.17v.78h.43v-.78c.333-.013.643-.068.93-.165a2.23 2.23 0 0 0 .75-.42 1.93 1.93 0 0 0 .505-.69c.123-.277.185-.602.185-.975 0-.36-.067-.663-.2-.91a1.904 1.904 0 0 0-.53-.62 2.957 2.957 0 0 0-.76-.41c-.287-.107-.58-.2-.88-.28v-2.11c.36 0 .621.09.785.27.163.18.251.44.265.78h1.14a1.99 1.99 0 0 0-.175-.86 1.721 1.721 0 0 0-.47-.61 1.996 1.996 0 0 0-.695-.36c-.267-.08-.55-.12-.85-.12V12h-.43v.78c-.3 0-.587.043-.86.13a2.302 2.302 0 0 0-.725.375c-.21.163-.377.367-.5.61a1.845 1.845 0 0 0-.185.845c0 .367.066.673.2.92.133.247.308.452.525.615.216.163.46.297.73.4.27.103.541.192.815.265v2.42c-.46-.013-.79-.147-.99-.4-.2-.253-.297-.6-.29-1.04zM35.13 14v2a3.704 3.704 0 0 1-.415-.125 1.33 1.33 0 0 1-.36-.195 1.013 1.013 0 0 1-.255-.29.795.795 0 0 1-.1-.41c0-.353.098-.605.295-.755.197-.15.475-.225.835-.225zm.87 5.33V17c.153.04.303.087.45.14.147.053.278.123.395.21.117.087.21.193.28.32a.96.96 0 0 1 .105.47c0 .4-.115.692-.345.875-.23.183-.525.288-.885.315z"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
|
|
@ -0,0 +1,176 @@
|
|||
odoo.define('website_sale_delivery.checkout', function (require) {
|
||||
'use strict';
|
||||
|
||||
var core = require('web.core');
|
||||
var publicWidget = require('web.public.widget');
|
||||
|
||||
var _t = core._t;
|
||||
var concurrency = require('web.concurrency');
|
||||
var dp = new concurrency.DropPrevious();
|
||||
|
||||
publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
selector: '.oe_website_sale',
|
||||
events: {
|
||||
'change select[name="shipping_id"]': '_onSetAddress',
|
||||
'click #delivery_carrier .o_delivery_carrier_select': '_onCarrierClick',
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
start: function () {
|
||||
var self = this;
|
||||
var $carriers = $('#delivery_carrier input[name="delivery_type"]');
|
||||
var $payButton = $('button[name="o_payment_submit_button"]');
|
||||
// Workaround to:
|
||||
// - update the amount/error on the label at first rendering
|
||||
// - prevent clicking on 'Pay Now' if the shipper rating fails
|
||||
if ($carriers.length > 0) {
|
||||
if ($carriers.filter(':checked').length === 0) {
|
||||
$payButton.prop('disabled', true);
|
||||
var disabledReasons = $payButton.data('disabled_reasons') || {};
|
||||
disabledReasons.carrier_selection = true;
|
||||
$payButton.data('disabled_reasons', disabledReasons);
|
||||
}
|
||||
$carriers.filter(':checked').click();
|
||||
}
|
||||
|
||||
// Asynchronously retrieve every carrier price
|
||||
_.each($carriers, function (carrierInput, k) {
|
||||
self._showLoading($(carrierInput));
|
||||
self._rpc({
|
||||
route: '/shop/carrier_rate_shipment',
|
||||
params: {
|
||||
'carrier_id': carrierInput.value,
|
||||
},
|
||||
}).then(self._handleCarrierUpdateResultBadge.bind(self));
|
||||
});
|
||||
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {jQuery} $carrierInput
|
||||
*/
|
||||
_showLoading: function ($carrierInput) {
|
||||
$carrierInput.siblings('.o_wsale_delivery_badge_price').empty();
|
||||
$carrierInput.siblings('.o_wsale_delivery_badge_price').append('<span class="fa fa-circle-o-notch fa-spin"/>');
|
||||
},
|
||||
/**
|
||||
* Update the total cost according to the selected shipping method
|
||||
*
|
||||
* @private
|
||||
* @param {float} amount : The new total amount of to be paid
|
||||
*/
|
||||
_updateShippingCost: function(amount){
|
||||
core.bus.trigger('update_shipping_cost', amount);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {Object} result
|
||||
*/
|
||||
_handleCarrierUpdateResult: function (result) {
|
||||
this._handleCarrierUpdateResultBadge(result);
|
||||
var $payButton = $('button[name="o_payment_submit_button"]');
|
||||
var $amountDelivery = $('#order_delivery .monetary_field');
|
||||
var $amountUntaxed = $('#order_total_untaxed .monetary_field');
|
||||
var $amountTax = $('#order_total_taxes .monetary_field');
|
||||
var $amountTotal = $('#order_total .monetary_field, #amount_total_summary.monetary_field');
|
||||
|
||||
if (result.status === true) {
|
||||
$amountDelivery.html(result.new_amount_delivery);
|
||||
$amountUntaxed.html(result.new_amount_untaxed);
|
||||
$amountTax.html(result.new_amount_tax);
|
||||
$amountTotal.html(result.new_amount_total);
|
||||
var disabledReasons = $payButton.data('disabled_reasons') || {};
|
||||
disabledReasons.carrier_selection = false;
|
||||
$payButton.data('disabled_reasons', disabledReasons);
|
||||
$payButton.prop('disabled', _.contains($payButton.data('disabled_reasons'), true));
|
||||
} else {
|
||||
$amountDelivery.html(result.new_amount_delivery);
|
||||
$amountUntaxed.html(result.new_amount_untaxed);
|
||||
$amountTax.html(result.new_amount_tax);
|
||||
$amountTotal.html(result.new_amount_total);
|
||||
}
|
||||
if (result.new_amount_total_raw !== undefined) {
|
||||
this._updateShippingCost(result.new_amount_total_raw);
|
||||
// reload page only when amount_total switches between zero and not zero
|
||||
const hasPaymentMethod = document.querySelector(
|
||||
"div[name='o_website_sale_free_cart']"
|
||||
) === null;
|
||||
const shouldDisplayPaymentMethod = result.new_amount_total_raw !== 0;
|
||||
if (hasPaymentMethod !== shouldDisplayPaymentMethod) {
|
||||
location.reload(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {Object} result
|
||||
*/
|
||||
_handleCarrierUpdateResultBadge: function (result) {
|
||||
var $carrierBadge = $('#delivery_carrier input[name="delivery_type"][value=' + result.carrier_id + '] ~ .o_wsale_delivery_badge_price');
|
||||
|
||||
if (result.status === true) {
|
||||
// if free delivery (`free_over` field), show 'Free', not '$0'
|
||||
if (result.is_free_delivery) {
|
||||
$carrierBadge.text(_t('Free'));
|
||||
} else {
|
||||
$carrierBadge.html(result.new_amount_delivery);
|
||||
}
|
||||
$carrierBadge.removeClass('o_wsale_delivery_carrier_error');
|
||||
} else {
|
||||
$carrierBadge.addClass('o_wsale_delivery_carrier_error');
|
||||
$carrierBadge.text(result.error_message);
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onCarrierClick: function (ev) {
|
||||
var $radio = $(ev.currentTarget).find('input[type="radio"]');
|
||||
this._showLoading($radio);
|
||||
$radio.prop("checked", true);
|
||||
var $payButton = $('button[name="o_payment_submit_button"]');
|
||||
$payButton.prop('disabled', true);
|
||||
var disabledReasons = $payButton.data('disabled_reasons') || {};
|
||||
disabledReasons.carrier_selection = true;
|
||||
$payButton.data('disabled_reasons', disabledReasons);
|
||||
dp.add(this._rpc({
|
||||
route: '/shop/update_carrier',
|
||||
params: {
|
||||
carrier_id: $radio.val(),
|
||||
},
|
||||
})).then(this._handleCarrierUpdateResult.bind(this));
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onSetAddress: function (ev) {
|
||||
var value = $(ev.currentTarget).val();
|
||||
var $providerFree = $('select[name="country_id"]:not(.o_provider_restricted), select[name="state_id"]:not(.o_provider_restricted)');
|
||||
var $providerRestricted = $('select[name="country_id"].o_provider_restricted, select[name="state_id"].o_provider_restricted');
|
||||
if (value === 0) {
|
||||
// Ship to the same address : only show shipping countries available for billing
|
||||
$providerFree.hide().attr('disabled', true);
|
||||
$providerRestricted.show().attr('disabled', false).change();
|
||||
} else {
|
||||
// Create a new address : show all countries available for billing
|
||||
$providerFree.show().attr('disabled', false).change();
|
||||
$providerRestricted.hide().attr('disabled', true);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
@include media-breakpoint-down(md) {
|
||||
.o_wsale_delivery_badge_price {
|
||||
max-width: 130px;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
#delivery_method .o_delivery_carrier_select:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
odoo.define('website_sale_delivery.tour', function (require) {
|
||||
'use strict';
|
||||
|
||||
var tour = require("web_tour.tour");
|
||||
const tourUtils = require('website_sale.tour_utils');
|
||||
|
||||
tour.register('check_free_delivery', {
|
||||
test: true,
|
||||
url: '/shop?search=office chair black',
|
||||
},
|
||||
[
|
||||
// Part 1: Check free delivery
|
||||
{
|
||||
content: "select office chair black",
|
||||
trigger: '.oe_product_cart a:contains("Office Chair Black TEST")',
|
||||
},
|
||||
{
|
||||
content: "click on add to cart",
|
||||
trigger: '#product_details #add_to_cart',
|
||||
},
|
||||
tourUtils.goToCart(),
|
||||
{
|
||||
content: "go to checkout",
|
||||
extra_trigger: '#cart_products input.js_quantity:propValue(1)',
|
||||
trigger: 'a[href*="/shop/checkout"]',
|
||||
},
|
||||
{
|
||||
content: "Check Free Delivery value to be zero",
|
||||
extra_trigger: '#delivery_carrier label:containsExact("Delivery Now Free Over 10")',
|
||||
trigger: "#delivery_carrier span:contains('0.0')"
|
||||
},
|
||||
// Part 2: check multiple delivery & price loaded asynchronously
|
||||
{
|
||||
content: "Ensure price was loaded asynchronously",
|
||||
extra_trigger: '#delivery_carrier input[name="delivery_type"]:checked',
|
||||
trigger: '#delivery_method .o_delivery_carrier_select:contains("20.0"):contains("The Poste")',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
{
|
||||
content: "Select `Wire Transfer` payment method",
|
||||
trigger: '#payment_method label:contains("Wire Transfer")',
|
||||
},
|
||||
{
|
||||
content: "Click on Pay Now",
|
||||
trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)',
|
||||
},
|
||||
{
|
||||
content: "Confirmation page should be shown",
|
||||
trigger: '#oe_structure_website_sale_confirmation_1',
|
||||
run: function () {}, // it's a check
|
||||
}
|
||||
]);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue