[REF] website_sale: update to the new module system
This commit is contained in:
@@ -1,101 +1,107 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
odoo.define('website_sale.editor', ['web.ajax', 'web.core', 'web.Model', 'website.contentMenu', 'website.snippets.editor', 'website.website'], function (require) {
|
||||
"use strict";
|
||||
|
||||
var website = openerp.website;
|
||||
var _t = openerp._t;
|
||||
var ajax = require('web.ajax');
|
||||
var core = require('web.core');
|
||||
var Model = require('web.Model');
|
||||
var contentMenu = require('website.contentMenu');
|
||||
var snippet_editor = require('website.snippets.editor');
|
||||
var website = require('website.website');
|
||||
|
||||
website.EditorBarContent.include({
|
||||
new_product: function() {
|
||||
website.prompt({
|
||||
id: "editor_new_product",
|
||||
window_title: _t("New Product"),
|
||||
input: "Product Name",
|
||||
}).then(function (name) {
|
||||
website.form('/shop/add_product', 'POST', {
|
||||
name: name
|
||||
var _t = core._t;
|
||||
|
||||
|
||||
contentMenu.EditorBarContent.include({
|
||||
new_product: function() {
|
||||
website.prompt({
|
||||
id: "editor_new_product",
|
||||
window_title: _t("New Product"),
|
||||
input: "Product Name",
|
||||
}).then(function (name) {
|
||||
website.form('/shop/add_product', 'POST', {
|
||||
name: name
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
snippet_editor.options.website_sale = snippet_editor.Option.extend({
|
||||
start: function () {
|
||||
var self = this;
|
||||
this.product_tmpl_id = parseInt(this.$target.find('[data-oe-model="product.template"]').data('oe-id'));
|
||||
|
||||
var size_x = parseInt(this.$target.attr("colspan") || 1);
|
||||
var size_y = parseInt(this.$target.attr("rowspan") || 1);
|
||||
|
||||
var $size = this.$el.find('ul[name="size"]');
|
||||
var $select = $size.find('tr:eq(0) td:lt('+size_x+')');
|
||||
if (size_y >= 2) $select = $select.add($size.find('tr:eq(1) td:lt('+size_x+')'));
|
||||
if (size_y >= 3) $select = $select.add($size.find('tr:eq(2) td:lt('+size_x+')'));
|
||||
if (size_y >= 4) $select = $select.add($size.find('tr:eq(3) td:lt('+size_x+')'));
|
||||
$select.addClass("selected");
|
||||
|
||||
new Model('product.style')
|
||||
.call('search_read', [[]])
|
||||
.then(function (data) {
|
||||
var $ul = self.$el.find('ul[name="style"]');
|
||||
for (var k in data) {
|
||||
$ul.append(
|
||||
$('<li data-style="'+data[k]['id']+'" data-toggle_class="'+data[k]['html_class']+'"/>')
|
||||
.append( $('<a/>').text(data[k]['name']) ));
|
||||
}
|
||||
self.set_active();
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
website.snippet.options.website_sale = website.snippet.Option.extend({
|
||||
start: function () {
|
||||
var self = this;
|
||||
this.product_tmpl_id = parseInt(this.$target.find('[data-oe-model="product.template"]').data('oe-id'));
|
||||
|
||||
var size_x = parseInt(this.$target.attr("colspan") || 1);
|
||||
var size_y = parseInt(this.$target.attr("rowspan") || 1);
|
||||
|
||||
var $size = this.$el.find('ul[name="size"]');
|
||||
var $select = $size.find('tr:eq(0) td:lt('+size_x+')');
|
||||
if (size_y >= 2) $select = $select.add($size.find('tr:eq(1) td:lt('+size_x+')'));
|
||||
if (size_y >= 3) $select = $select.add($size.find('tr:eq(2) td:lt('+size_x+')'));
|
||||
if (size_y >= 4) $select = $select.add($size.find('tr:eq(3) td:lt('+size_x+')'));
|
||||
$select.addClass("selected");
|
||||
|
||||
website.session.model('product.style')
|
||||
.call('search_read', [[]])
|
||||
.then(function (data) {
|
||||
var $ul = self.$el.find('ul[name="style"]');
|
||||
for (var k in data) {
|
||||
$ul.append(
|
||||
$('<li data-style="'+data[k]['id']+'" data-toggle_class="'+data[k]['html_class']+'"/>')
|
||||
.append( $('<a/>').text(data[k]['name']) ));
|
||||
}
|
||||
self.set_active();
|
||||
});
|
||||
|
||||
this.bind_resize();
|
||||
},
|
||||
reload: function () {
|
||||
if (location.href.match(/\?enable_editor/)) {
|
||||
location.reload();
|
||||
} else {
|
||||
location.href = location.href.replace(/\?(enable_editor=1&)?|#.*|$/, '?enable_editor=1&');
|
||||
}
|
||||
},
|
||||
bind_resize: function () {
|
||||
var self = this;
|
||||
this.$el.on('mouseenter', 'ul[name="size"] table', function (event) {
|
||||
$(event.currentTarget).addClass("oe_hover");
|
||||
});
|
||||
this.$el.on('mouseleave', 'ul[name="size"] table', function (event) {
|
||||
$(event.currentTarget).removeClass("oe_hover");
|
||||
});
|
||||
this.$el.on('mouseover', 'ul[name="size"] td', function (event) {
|
||||
var $td = $(event.currentTarget);
|
||||
var $table = $td.closest("table");
|
||||
var x = $td.index()+1;
|
||||
var y = $td.parent().index()+1;
|
||||
|
||||
var tr = [];
|
||||
for (var yi=0; yi<y; yi++) tr.push("tr:eq("+yi+")");
|
||||
var $select_tr = $table.find(tr.join(","));
|
||||
var td = [];
|
||||
for (var xi=0; xi<x; xi++) td.push("td:eq("+xi+")");
|
||||
var $select_td = $select_tr.find(td.join(","));
|
||||
|
||||
$table.find("td").removeClass("select");
|
||||
$select_td.addClass("select");
|
||||
});
|
||||
this.$el.on('click', 'ul[name="size"] td', function (event) {
|
||||
var $td = $(event.currentTarget);
|
||||
var $data = $td.closest(".js_options:first");
|
||||
var x = $td.index()+1;
|
||||
var y = $td.parent().index()+1;
|
||||
openerp.jsonRpc('/shop/change_size', 'call', {'id': self.product_tmpl_id, 'x': x, 'y': y})
|
||||
.then(self.reload);
|
||||
});
|
||||
},
|
||||
style: function (type, value, $li) {
|
||||
if(type !== "click") return;
|
||||
openerp.jsonRpc('/shop/change_styles', 'call', {'id': this.product_tmpl_id, 'style_id': value});
|
||||
},
|
||||
go_to: function (type, value) {
|
||||
if(type !== "click") return;
|
||||
openerp.jsonRpc('/shop/change_sequence', 'call', {'id': this.product_tmpl_id, 'sequence': value})
|
||||
.then(this.reload);
|
||||
this.bind_resize();
|
||||
},
|
||||
reload: function () {
|
||||
if (location.href.match(/\?enable_editor/)) {
|
||||
location.reload();
|
||||
} else {
|
||||
location.href = location.href.replace(/\?(enable_editor=1&)?|#.*|$/, '?enable_editor=1&');
|
||||
}
|
||||
});
|
||||
},
|
||||
bind_resize: function () {
|
||||
var self = this;
|
||||
this.$el.on('mouseenter', 'ul[name="size"] table', function (event) {
|
||||
$(event.currentTarget).addClass("oe_hover");
|
||||
});
|
||||
this.$el.on('mouseleave', 'ul[name="size"] table', function (event) {
|
||||
$(event.currentTarget).removeClass("oe_hover");
|
||||
});
|
||||
this.$el.on('mouseover', 'ul[name="size"] td', function (event) {
|
||||
var $td = $(event.currentTarget);
|
||||
var $table = $td.closest("table");
|
||||
var x = $td.index()+1;
|
||||
var y = $td.parent().index()+1;
|
||||
|
||||
})();
|
||||
var tr = [];
|
||||
for (var yi=0; yi<y; yi++) tr.push("tr:eq("+yi+")");
|
||||
var $select_tr = $table.find(tr.join(","));
|
||||
var td = [];
|
||||
for (var xi=0; xi<x; xi++) td.push("td:eq("+xi+")");
|
||||
var $select_td = $select_tr.find(td.join(","));
|
||||
|
||||
$table.find("td").removeClass("select");
|
||||
$select_td.addClass("select");
|
||||
});
|
||||
this.$el.on('click', 'ul[name="size"] td', function (event) {
|
||||
var $td = $(event.currentTarget);
|
||||
var x = $td.index()+1;
|
||||
var y = $td.parent().index()+1;
|
||||
ajax.jsonRpc('/shop/change_size', 'call', {'id': self.product_tmpl_id, 'x': x, 'y': y})
|
||||
.then(self.reload);
|
||||
});
|
||||
},
|
||||
style: function (type, value, $li) {
|
||||
if(type !== "click") return;
|
||||
ajax.jsonRpc('/shop/change_styles', 'call', {'id': this.product_tmpl_id, 'style_id': value});
|
||||
},
|
||||
go_to: function (type, value) {
|
||||
if(type !== "click") return;
|
||||
ajax.jsonRpc('/shop/change_sequence', 'call', {'id': this.product_tmpl_id, 'sequence': value})
|
||||
.then(this.reload);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
odoo.define('website_sale.website_sale', ['web.ajax'], function (require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.oe_website_sale').each(function () {
|
||||
var oe_website_sale = this;
|
||||
|
||||
var $shippingDifferent = $("select[name='shipping_id']", oe_website_sale);
|
||||
$shippingDifferent.change(function (event) {
|
||||
$shippingDifferent.change(function () {
|
||||
var value = +$shippingDifferent.val();
|
||||
var data = $shippingDifferent.find("option:selected").data();
|
||||
var $snipping = $(".js_shipping", oe_website_sale);
|
||||
@@ -29,7 +34,7 @@ $('.oe_website_sale').each(function () {
|
||||
var value = parseInt($input.val(), 10);
|
||||
var line_id = parseInt($input.data('line-id'),10);
|
||||
if (isNaN(value)) value = 0;
|
||||
openerp.jsonRpc("/shop/cart/update_json", 'call', {
|
||||
ajax.jsonRpc("/shop/cart/update_json", 'call', {
|
||||
'line_id': line_id,
|
||||
'product_id': parseInt($input.data('product-id'),10),
|
||||
'set_qty': value})
|
||||
@@ -47,7 +52,7 @@ $('.oe_website_sale').each(function () {
|
||||
$("#cart_total").replaceWith(data['website_sale.total']);
|
||||
if (data.warning) {
|
||||
var cart_alert = $('.oe_cart').parent().find('#data_warning');
|
||||
if (cart_alert.length == 0) {
|
||||
if (cart_alert.length === 0) {
|
||||
$('.oe_cart').prepend('<div class="alert alert-danger alert-dismissable" role="alert" id="data_warning">'+
|
||||
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> ' + data.warning + '</div>');
|
||||
}
|
||||
@@ -81,7 +86,7 @@ $('.oe_website_sale').each(function () {
|
||||
});
|
||||
|
||||
// change price when they are variants
|
||||
$('form.js_add_cart_json label', oe_website_sale).on('mouseup touchend', function (ev) {
|
||||
$('form.js_add_cart_json label', oe_website_sale).on('mouseup touchend', function () {
|
||||
var $label = $(this);
|
||||
var $price = $label.parents("form:first").find(".oe_price .oe_currency_value");
|
||||
if (!$price.data("price")) {
|
||||
@@ -92,7 +97,7 @@ $('.oe_website_sale').each(function () {
|
||||
$price.html(value + (dec < 0.01 ? ".00" : (dec < 1 ? "0" : "") ));
|
||||
});
|
||||
// hightlight selected color
|
||||
$('.css_attribute_color input', oe_website_sale).on('change', function (ev) {
|
||||
$('.css_attribute_color input', oe_website_sale).on('change', function () {
|
||||
$('.css_attribute_color').removeClass("active");
|
||||
$('.css_attribute_color:has(input:checked)').addClass("active");
|
||||
});
|
||||
@@ -103,7 +108,7 @@ $('.oe_website_sale').each(function () {
|
||||
return price + (dec ? '' : '.0') + (dec%10 ? '' : '0');
|
||||
}
|
||||
|
||||
$(oe_website_sale).on('change', 'input.js_product_change', function (ev) {
|
||||
$(oe_website_sale).on('change', 'input.js_product_change', function () {
|
||||
var $parent = $(this).closest('.js_product');
|
||||
$parent.find(".oe_default_price:first .oe_currency_value").html( price_to_str(+$(this).data('lst_price')) );
|
||||
$parent.find(".oe_price:first .oe_currency_value").html(price_to_str(+$(this).data('price')) );
|
||||
@@ -112,7 +117,7 @@ $('.oe_website_sale').each(function () {
|
||||
$img.attr("src", "/website/image/product.product/" + $(this).val() + "/image");
|
||||
});
|
||||
|
||||
$(oe_website_sale).on('change', 'input.js_variant_change, select.js_variant_change', function (ev) {
|
||||
$(oe_website_sale).on('change', 'input.js_variant_change, select.js_variant_change', function () {
|
||||
var $ul = $(this).parents('ul.js_add_cart_variants:first');
|
||||
var $parent = $ul.closest('.js_product');
|
||||
var $product_id = $parent.find('input.product_id').first();
|
||||
@@ -197,3 +202,5 @@ $('.oe_website_sale').each(function () {
|
||||
$(oe_website_sale).find("select[name='shipping_country_id']").change();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
odoo.define('website_sale.payment', ['web.ajax'], function (require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// When choosing an acquirer, display its Pay Now button
|
||||
@@ -18,9 +23,11 @@ $(document).ready(function () {
|
||||
if (! acquirer_id) {
|
||||
return false;
|
||||
}
|
||||
openerp.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {}).then(function (data) {
|
||||
ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {}).then(function () {
|
||||
$form.submit();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,95 +1,98 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
openerp.Tour.register({
|
||||
id: 'shop_buy_product',
|
||||
name: "Try to buy products",
|
||||
path: '/shop',
|
||||
mode: 'test',
|
||||
steps: [
|
||||
{
|
||||
title: "search ipod",
|
||||
element: 'form:has(input[name="search"]) a.a-submit',
|
||||
onload: function() {
|
||||
$('input[name="search"]').val("ipod");
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "select ipod",
|
||||
element: '.oe_product_cart a:contains("iPod")',
|
||||
},
|
||||
{
|
||||
title: "select ipod 32GB",
|
||||
waitFor: '#product_detail',
|
||||
element: 'label:contains(32 GB) input',
|
||||
},
|
||||
{
|
||||
title: "click on add to cart",
|
||||
waitFor: 'label:contains(32 GB) input:propChecked',
|
||||
element: '#product_detail form[action^="/shop/cart/update"] .btn',
|
||||
},
|
||||
{
|
||||
title: "add suggested",
|
||||
waitNot: '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
|
||||
element: '.oe_cart a:contains("Add to Cart")',
|
||||
},
|
||||
{
|
||||
title: "add one more iPod",
|
||||
waitFor: '.my_cart_quantity:contains(2)',
|
||||
element: '#cart_products tr:contains("32 GB") a.js_add_cart_json:eq(1)',
|
||||
},
|
||||
{
|
||||
title: "remove Headphones",
|
||||
waitFor: '#cart_products tr:contains("32 GB") input.js_quantity:propValue(2)',
|
||||
element: '#cart_products tr:contains("Apple In-Ear Headphones") a.js_add_cart_json:first',
|
||||
},
|
||||
{
|
||||
title: "set one iPod",
|
||||
waitNot: '#cart_products tr:contains("Apple In-Ear Headphones")',
|
||||
element: '#cart_products input.js_quantity',
|
||||
sampleText: '1',
|
||||
},
|
||||
{
|
||||
title: "go to checkout",
|
||||
waitFor: '#cart_products input.js_quantity:propValue(1)',
|
||||
element: 'a[href="/shop/checkout"]',
|
||||
},
|
||||
{
|
||||
title: "test with input error",
|
||||
element: 'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
|
||||
onload: function (tour) {
|
||||
$("input[name='phone']").val("");
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "test without input error",
|
||||
waitFor: 'form[action="/shop/confirm_order"] .has-error',
|
||||
element: 'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
|
||||
onload: function (tour) {
|
||||
if ($("input[name='name']").val() === "")
|
||||
$("input[name='name']").val("website_sale-test-shoptest");
|
||||
if ($("input[name='email']").val() === "")
|
||||
$("input[name='email']").val("website_sale_test_shoptest@websitesaletest.odoo.com");
|
||||
$("input[name='phone']").val("123");
|
||||
$("input[name='street2']").val("123");
|
||||
$("input[name='city']").val("123");
|
||||
$("input[name='zip']").val("123");
|
||||
$("select[name='country_id']").val("21");
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "select payment",
|
||||
element: '#payment_method label:has(img[title="Wire Transfer"]) input',
|
||||
},
|
||||
{
|
||||
title: "Pay Now",
|
||||
waitFor: '#payment_method label:has(input:checked):has(img[title="Wire Transfer"])',
|
||||
element: '.oe_sale_acquirer_button .btn[type="submit"]:visible',
|
||||
},
|
||||
{
|
||||
title: "finish",
|
||||
waitFor: '.oe_website_sale:contains("Thank you for your order")',
|
||||
}
|
||||
]
|
||||
});
|
||||
odoo.define('website_sale.tour', ['web.Tour'], function (require) {
|
||||
'use strict';
|
||||
|
||||
}());
|
||||
var Tour = require('web.Tour');
|
||||
|
||||
Tour.register({
|
||||
id: 'shop_buy_product',
|
||||
name: "Try to buy products",
|
||||
path: '/shop',
|
||||
mode: 'test',
|
||||
steps: [
|
||||
{
|
||||
title: "search ipod",
|
||||
element: 'form:has(input[name="search"]) a.a-submit',
|
||||
onload: function() {
|
||||
$('input[name="search"]').val("ipod");
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "select ipod",
|
||||
element: '.oe_product_cart a:contains("iPod")',
|
||||
},
|
||||
{
|
||||
title: "select ipod 32GB",
|
||||
waitFor: '#product_detail',
|
||||
element: 'label:contains(32 GB) input',
|
||||
},
|
||||
{
|
||||
title: "click on add to cart",
|
||||
waitFor: 'label:contains(32 GB) input:propChecked',
|
||||
element: '#product_detail form[action^="/shop/cart/update"] .btn',
|
||||
},
|
||||
{
|
||||
title: "add suggested",
|
||||
waitNot: '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
|
||||
element: '.oe_cart a:contains("Add to Cart")',
|
||||
},
|
||||
{
|
||||
title: "add one more iPod",
|
||||
waitFor: '.my_cart_quantity:contains(2)',
|
||||
element: '#cart_products tr:contains("32 GB") a.js_add_cart_json:eq(1)',
|
||||
},
|
||||
{
|
||||
title: "remove Headphones",
|
||||
waitFor: '#cart_products tr:contains("32 GB") input.js_quantity:propValue(2)',
|
||||
element: '#cart_products tr:contains("Apple In-Ear Headphones") a.js_add_cart_json:first',
|
||||
},
|
||||
{
|
||||
title: "set one iPod",
|
||||
waitNot: '#cart_products tr:contains("Apple In-Ear Headphones")',
|
||||
element: '#cart_products input.js_quantity',
|
||||
sampleText: '1',
|
||||
},
|
||||
{
|
||||
title: "go to checkout",
|
||||
waitFor: '#cart_products input.js_quantity:propValue(1)',
|
||||
element: 'a[href="/shop/checkout"]',
|
||||
},
|
||||
{
|
||||
title: "test with input error",
|
||||
element: 'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
|
||||
onload: function (tour) {
|
||||
$("input[name='phone']").val("");
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "test without input error",
|
||||
waitFor: 'form[action="/shop/confirm_order"] .has-error',
|
||||
element: 'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
|
||||
onload: function (tour) {
|
||||
if ($("input[name='name']").val() === "")
|
||||
$("input[name='name']").val("website_sale-test-shoptest");
|
||||
if ($("input[name='email']").val() === "")
|
||||
$("input[name='email']").val("website_sale_test_shoptest@websitesaletest.odoo.com");
|
||||
$("input[name='phone']").val("123");
|
||||
$("input[name='street2']").val("123");
|
||||
$("input[name='city']").val("123");
|
||||
$("input[name='zip']").val("123");
|
||||
$("select[name='country_id']").val("21");
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "select payment",
|
||||
element: '#payment_method label:has(img[title="Wire Transfer"]) input',
|
||||
},
|
||||
{
|
||||
title: "Pay Now",
|
||||
waitFor: '#payment_method label:has(input:checked):has(img[title="Wire Transfer"])',
|
||||
element: '.oe_sale_acquirer_button .btn[type="submit"]:visible',
|
||||
},
|
||||
{
|
||||
title: "finish",
|
||||
waitFor: '.oe_website_sale:contains("Thank you for your order")',
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
odoo.define('website_sale.tour_shop', ['web.core', 'web.Tour', 'website.website'], function (require) {
|
||||
'use strict';
|
||||
|
||||
var _t = openerp._t;
|
||||
var website = openerp.website;
|
||||
website.ready().done(function() {
|
||||
openerp.Tour.register({
|
||||
var core = require('web.core');
|
||||
var Tour = require('web.Tour');
|
||||
var website = require('website.website');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
website.ready().done(function () {
|
||||
Tour.register({
|
||||
id: 'shop',
|
||||
name: _t("Create a product"),
|
||||
steps: [
|
||||
@@ -108,6 +112,6 @@
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
odoo.define('website_sale.tracking', function(require) {
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Watching a product
|
||||
if ($("#product_detail.oe_website_sale").length) {
|
||||
prod_id = $("input[name='product_id']").attr('value');
|
||||
var prod_id = $("input[name='product_id']").attr('value');
|
||||
vpv("/stats/ecom/product_view/" + prod_id);
|
||||
}
|
||||
|
||||
// Add a product into the cart
|
||||
$(".oe_website_sale form[action='/shop/cart/update'] a.a-submit").on('click', function(o) {
|
||||
prod_id = $("input[name='product_id']").attr('value');
|
||||
var prod_id = $("input[name='product_id']").attr('value');
|
||||
vpv("/stats/ecom/product_add_to_cart/" + prod_id);
|
||||
});
|
||||
|
||||
@@ -36,10 +40,10 @@ $(document).ready(function () {
|
||||
if ($(".oe_website_sale div.oe_cart div.oe_website_sale_tx_status").length) {
|
||||
track_ga('require', 'ecommerce');
|
||||
|
||||
order_id = $(".oe_website_sale div.oe_cart div.oe_website_sale_tx_status").data("order-id");
|
||||
var order_id = $(".oe_website_sale div.oe_cart div.oe_website_sale_tx_status").data("order-id");
|
||||
vpv("/stats/ecom/order_confirmed/" + order_id);
|
||||
|
||||
openerp.jsonRpc("/shop/tracking_last_order/").then(function(o) {
|
||||
ajax.jsonRpc("/shop/tracking_last_order/").then(function(o) {
|
||||
track_ga('ecommerce:clear');
|
||||
|
||||
if (o.transaction && o.lines) {
|
||||
@@ -65,3 +69,5 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
odoo.define('website_sale.validate', ['web.ajax'], function(require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var _poll_nbr = 0;
|
||||
@@ -8,7 +13,7 @@ $(document).ready(function () {
|
||||
return;
|
||||
}
|
||||
var order_id = order_node.data('order-id');
|
||||
return openerp.jsonRpc('/shop/payment/get_status/' + order_id, 'call', {
|
||||
return ajax.jsonRpc('/shop/payment/get_status/' + order_id, 'call', {
|
||||
}).then(function (result) {
|
||||
_poll_nbr += 1;
|
||||
if(result.recall && _poll_nbr <= 5){
|
||||
@@ -20,3 +25,5 @@ $(document).ready(function () {
|
||||
|
||||
payment_transaction_poll_status();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,78 +1,86 @@
|
||||
odoo.define('website_sale.website_sale', ['web.ajax', 'website.website'], function(require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
var website = require('website.website');
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
|
||||
.off('click')
|
||||
.removeClass('a-submit')
|
||||
.click(function (event) {
|
||||
var $form = $(this).closest('form');
|
||||
var quantity = parseFloat($form.find('input[name="add_qty"]').val() || 1);
|
||||
var product_id = parseInt($form.find('input[type="hidden"][name="product_id"], input[type="radio"][name="product_id"]:checked').first().val(),10);
|
||||
event.preventDefault();
|
||||
openerp.jsonRpc("/shop/modal", 'call', {
|
||||
'product_id': product_id,
|
||||
kwargs: {
|
||||
context: openerp.website.get_context()
|
||||
},
|
||||
}).then(function (modal) {
|
||||
var $modal = $(modal);
|
||||
$('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
|
||||
.off('click')
|
||||
.removeClass('a-submit')
|
||||
.click(function (event) {
|
||||
var $form = $(this).closest('form');
|
||||
var quantity = parseFloat($form.find('input[name="add_qty"]').val() || 1);
|
||||
var product_id = parseInt($form.find('input[type="hidden"][name="product_id"], input[type="radio"][name="product_id"]:checked').first().val(),10);
|
||||
event.preventDefault();
|
||||
ajax.jsonRpc("/shop/modal", 'call', {
|
||||
'product_id': product_id,
|
||||
kwargs: {
|
||||
context: website.get_context()
|
||||
},
|
||||
}).then(function (modal) {
|
||||
var $modal = $(modal);
|
||||
|
||||
$modal.find('img:first').attr("src", "/website/image/product.product/" + product_id + "/image_medium");
|
||||
$modal.find('img:first').attr("src", "/website/image/product.product/" + product_id + "/image_medium");
|
||||
|
||||
$modal.appendTo($form)
|
||||
.modal()
|
||||
.on('hidden.bs.modal', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
$modal.appendTo($form)
|
||||
.modal()
|
||||
.on('hidden.bs.modal', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$modal.on('click', '.a-submit', function () {
|
||||
var $a = $(this);
|
||||
$form.ajaxSubmit({
|
||||
url: '/shop/cart/update_option',
|
||||
success: function (quantity) {
|
||||
if (!$a.hasClass('js_goto_shop')) {
|
||||
window.location.href = window.location.href.replace(/shop([\/?].*)?$/, "shop/cart");
|
||||
}
|
||||
var $q = $(".my_cart_quantity");
|
||||
$q.parent().parent().removeClass("hidden", !quantity);
|
||||
$q.html(quantity).hide().fadeIn(600);
|
||||
$modal.on('click', '.a-submit', function () {
|
||||
var $a = $(this);
|
||||
$form.ajaxSubmit({
|
||||
url: '/shop/cart/update_option',
|
||||
success: function (quantity) {
|
||||
if (!$a.hasClass('js_goto_shop')) {
|
||||
window.location.href = window.location.href.replace(/shop([\/?].*)?$/, "shop/cart");
|
||||
}
|
||||
});
|
||||
$modal.modal('hide');
|
||||
});
|
||||
|
||||
$modal.on("click", "a.js_add, a.js_remove", function (event) {
|
||||
event.preventDefault();
|
||||
var $parent = $(this).parents('.js_product:first');
|
||||
$parent.find("a.js_add, span.js_remove").toggleClass("hidden");
|
||||
$parent.find("input.js_optional_same_quantity").val( $(this).hasClass("js_add") ? 1 : 0 );
|
||||
var $remove = $parent.find(".js_remove");
|
||||
});
|
||||
|
||||
$modal.on("change", "input.js_quantity", function (event) {
|
||||
var qty = parseFloat($(this).val());
|
||||
if (qty === 1) {
|
||||
$(".js_remove .js_items").addClass("hidden");
|
||||
$(".js_remove .js_item").removeClass("hidden");
|
||||
} else {
|
||||
$(".js_remove .js_items").removeClass("hidden").text($(".js_remove .js_items:first").text().replace(/[0-9.,]+/, qty));
|
||||
$(".js_remove .js_item").addClass("hidden");
|
||||
var $q = $(".my_cart_quantity");
|
||||
$q.parent().parent().removeClass("hidden", !quantity);
|
||||
$q.html(quantity).hide().fadeIn(600);
|
||||
}
|
||||
});
|
||||
|
||||
$modal.find('input[name="add_qty"]').val(quantity).change();
|
||||
$('ul.js_add_cart_variants').each(function () {
|
||||
$('input.js_variant_change, select.js_variant_change', this).first().trigger('change');
|
||||
});
|
||||
$modal.modal('hide');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#cart_products input.js_quantity').change(function () {
|
||||
var value = $(this).val();
|
||||
var $next = $(this).closest('tr').next('.optional_product');
|
||||
while($next.length) {
|
||||
$next.find('.js_quantity').text(value);
|
||||
$next = $next.next('.optional_product');
|
||||
}
|
||||
|
||||
$modal.on("click", "a.js_add, a.js_remove", function (event) {
|
||||
event.preventDefault();
|
||||
var $parent = $(this).parents('.js_product:first');
|
||||
$parent.find("a.js_add, span.js_remove").toggleClass("hidden");
|
||||
$parent.find("input.js_optional_same_quantity").val( $(this).hasClass("js_add") ? 1 : 0 );
|
||||
var $remove = $parent.find(".js_remove");
|
||||
});
|
||||
|
||||
$modal.on("change", "input.js_quantity", function () {
|
||||
var qty = parseFloat($(this).val());
|
||||
if (qty === 1) {
|
||||
$(".js_remove .js_items").addClass("hidden");
|
||||
$(".js_remove .js_item").removeClass("hidden");
|
||||
} else {
|
||||
$(".js_remove .js_items").removeClass("hidden").text($(".js_remove .js_items:first").text().replace(/[0-9.,]+/, qty));
|
||||
$(".js_remove .js_item").addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
$modal.find('input[name="add_qty"]').val(quantity).change();
|
||||
$('ul.js_add_cart_variants').each(function () {
|
||||
$('input.js_variant_change, select.js_variant_change', this).first().trigger('change');
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#cart_products input.js_quantity').change(function () {
|
||||
var value = $(this).val();
|
||||
var $next = $(this).closest('tr').next('.optional_product');
|
||||
while($next.length) {
|
||||
$next.find('.js_quantity').text(value);
|
||||
$next = $next.next('.optional_product');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,94 +1,99 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
var _t = openerp._t;
|
||||
var steps = openerp.Tour.tours.shop_buy_product.steps;
|
||||
for (var k=0; k<steps.length; k++) {
|
||||
if (steps[k].title === "click on add to cart") {
|
||||
steps.splice(k+1, 0, {
|
||||
title: _t("click in modal on 'Proceed to checkout' button"),
|
||||
element: '.modal a:contains("Proceed to checkout")',
|
||||
});
|
||||
break;
|
||||
}
|
||||
odoo.define('website_sale.test', ['web.core', 'web.Tour'], function (require) {
|
||||
'use strict';
|
||||
|
||||
var core = require('web.core');
|
||||
var Tour = require('web.Tour');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
var steps = Tour.tours.shop_buy_product.steps;
|
||||
for (var k=0; k<steps.length; k++) {
|
||||
if (steps[k].title === "click on add to cart") {
|
||||
steps.splice(k+1, 0, {
|
||||
title: _t("click in modal on 'Proceed to checkout' button"),
|
||||
element: '.modal a:contains("Proceed to checkout")',
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
openerp.Tour.register({
|
||||
id: 'shop_customize',
|
||||
name: "Customize the page and search a product",
|
||||
path: '/shop',
|
||||
mode: 'test',
|
||||
steps: [
|
||||
{
|
||||
title: "open customize menu",
|
||||
element: '#customize-menu-button',
|
||||
},
|
||||
{
|
||||
title: "click on 'Product Attribute's Filters'",
|
||||
element: "#customize-menu a:contains(Product Attribute's Filters)",
|
||||
},
|
||||
{
|
||||
title: "select product attribute memory 16 GB",
|
||||
waitNot: '#customize-menu:visible .dropdown-menu:visible',
|
||||
element: 'form.js_attributes label:contains(16 GB) input:not(:checked)',
|
||||
},
|
||||
{
|
||||
title: "check the selection",
|
||||
waitFor: 'form.js_attributes label:contains(16 GB) input:checked',
|
||||
},
|
||||
{
|
||||
title: "select iPad",
|
||||
waitNot: '.oe_website_sale .oe_product_cart:eq(2)',
|
||||
element: '.oe_product_cart a:contains("iPad")',
|
||||
},
|
||||
{
|
||||
title: "click on 'Add to Cart' button",
|
||||
element: "a:contains(Add to Cart)",
|
||||
},
|
||||
{
|
||||
title: "add an optional Warranty",
|
||||
element: ".js_product:contains(Warranty) a:contains(Add to Cart)",
|
||||
},
|
||||
{
|
||||
title: "click in modal on 'Proceed to checkout' button",
|
||||
waitFor: '.js_product:contains(Warranty) a:contains(Add to Cart):hidden',
|
||||
element: '.modal-dialog a:contains("Proceed to checkout")',
|
||||
},
|
||||
{
|
||||
title: "check quantity",
|
||||
waitFor: '.my_cart_quantity:containsExact(2)',
|
||||
},
|
||||
{
|
||||
title: "check optional product",
|
||||
waitFor: '.optional_product',
|
||||
},
|
||||
{
|
||||
title: "remove iPad from cart",
|
||||
element: '#cart_products a.js_add_cart_json:first',
|
||||
},
|
||||
{
|
||||
title: "check optional product is removed",
|
||||
waitNot: '.optional_product',
|
||||
},
|
||||
{
|
||||
title: "click on shop",
|
||||
element: "a:contains(Shop)",
|
||||
waitNot: '#products_grid_before .js_attributes',
|
||||
},
|
||||
{
|
||||
title: "open customize menu bis",
|
||||
waitFor: '#products_grid_before .js_attributes',
|
||||
element: '#customize-menu-button',
|
||||
},
|
||||
{
|
||||
title: "remove 'Product Attribute's Filters'",
|
||||
element: "#customize-menu a:contains(Product Attribute's Filters):has(.fa-check-square-o)",
|
||||
},
|
||||
{
|
||||
title: "finish",
|
||||
waitNot: '#products_grid_before .js_attributes',
|
||||
waitFor: 'li:has(.my_cart_quantity):hidden',
|
||||
},
|
||||
]
|
||||
});
|
||||
Tour.register({
|
||||
id: 'shop_customize',
|
||||
name: "Customize the page and search a product",
|
||||
path: '/shop',
|
||||
mode: 'test',
|
||||
steps: [
|
||||
{
|
||||
title: "open customize menu",
|
||||
element: '#customize-menu-button',
|
||||
},
|
||||
{
|
||||
title: "click on 'Product Attribute's Filters'",
|
||||
element: "#customize-menu a:contains(Product Attribute's Filters)",
|
||||
},
|
||||
{
|
||||
title: "select product attribute memory 16 GB",
|
||||
waitNot: '#customize-menu:visible .dropdown-menu:visible',
|
||||
element: 'form.js_attributes label:contains(16 GB) input:not(:checked)',
|
||||
},
|
||||
{
|
||||
title: "check the selection",
|
||||
waitFor: 'form.js_attributes label:contains(16 GB) input:checked',
|
||||
},
|
||||
{
|
||||
title: "select iPad",
|
||||
waitNot: '.oe_website_sale .oe_product_cart:eq(2)',
|
||||
element: '.oe_product_cart a:contains("iPad")',
|
||||
},
|
||||
{
|
||||
title: "click on 'Add to Cart' button",
|
||||
element: "a:contains(Add to Cart)",
|
||||
},
|
||||
{
|
||||
title: "add an optional Warranty",
|
||||
element: ".js_product:contains(Warranty) a:contains(Add to Cart)",
|
||||
},
|
||||
{
|
||||
title: "click in modal on 'Proceed to checkout' button",
|
||||
waitFor: '.js_product:contains(Warranty) a:contains(Add to Cart):hidden',
|
||||
element: '.modal-dialog a:contains("Proceed to checkout")',
|
||||
},
|
||||
{
|
||||
title: "check quantity",
|
||||
waitFor: '.my_cart_quantity:containsExact(2)',
|
||||
},
|
||||
{
|
||||
title: "check optional product",
|
||||
waitFor: '.optional_product',
|
||||
},
|
||||
{
|
||||
title: "remove iPad from cart",
|
||||
element: '#cart_products a.js_add_cart_json:first',
|
||||
},
|
||||
{
|
||||
title: "check optional product is removed",
|
||||
waitNot: '.optional_product',
|
||||
},
|
||||
{
|
||||
title: "click on shop",
|
||||
element: "a:contains(Shop)",
|
||||
waitNot: '#products_grid_before .js_attributes',
|
||||
},
|
||||
{
|
||||
title: "open customize menu bis",
|
||||
waitFor: '#products_grid_before .js_attributes',
|
||||
element: '#customize-menu-button',
|
||||
},
|
||||
{
|
||||
title: "remove 'Product Attribute's Filters'",
|
||||
element: "#customize-menu a:contains(Product Attribute's Filters):has(.fa-check-square-o)",
|
||||
},
|
||||
{
|
||||
title: "finish",
|
||||
waitNot: '#products_grid_before .js_attributes',
|
||||
waitFor: 'li:has(.my_cart_quantity):hidden',
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user