[IMP]forward port wishlist changes to flectra

This commit is contained in:
mayank 2018-04-27 16:44:54 +05:30
parent 4a9499557e
commit 899cd0f216
6 changed files with 151 additions and 11 deletions

View File

@ -39,3 +39,8 @@ class WebsiteSaleWishlist(WebsiteSale):
return request.redirect("/shop")
return request.render("website_sale_wishlist.product_wishlist", dict(wishes=values))
@http.route(['/shop/wishlist/remove/<model("product.wishlist"):wish>'], type='json', auth="public", website=True)
def rm_from_wishlist(self, wish, **kw):
wish.active = False
return True

View File

@ -0,0 +1,130 @@
flectra.define('website_sale_wishlist.tour', function (require) {
'use strict';
var tour = require("web_tour.tour");
var base = require("web_editor.base");
tour.register('shop_wishlist', {
test: true,
url: '/shop',
wait_for: base.ready(),
},
[
{
content: "click on add to wishlist",
trigger: '.o_add_wishlist',
},
{
content: "go to wishlist",
extra_trigger: ".label:contains(1)",
trigger: 'a[href="/shop/wishlist"]',
},
{
content: "remove first item in whishlist",
trigger: 'a.o_wish_rm:first',
},
{
content: "go back to the store",
trigger: "a[href='/shop']"
},
{
content: "click on add to wishlist",
trigger: '.o_add_wishlist',
},
{
content: "check value of wishlist and go to login",
extra_trigger: ".my_wish_quantity:contains(1)",
trigger: 'a[href="/web/login"]',
},
{
content: "submit login",
trigger: ".oe_login_form",
run: function (){
$('.oe_login_form input[name="login"]').val("admin");
$('.oe_login_form input[name="password"]').val("admin");
$('.oe_login_form input[name="redirect"]').val("/shop");
$('.oe_login_form').submit();
},
},
{
content: "check that logged in and search for ipad",
extra_trigger: 'li span:contains(Administrator)',
trigger: 'form input[name="search"]',
run: "text ipad retina",
},
{
content: "submit search",
trigger: 'form:has(input[name="search"]) .oe_search_button',
},
{
content: "click on ipad",
trigger: '.oe_product_cart a:contains("iPad Retina Display")',
},
{
content: "select ipad 32GB",
extra_trigger: '#product_detail',
trigger: 'label:contains(32 GB) input',
},
{
content: "click on add to wishlist",
trigger: '#product_detail .o_add_wishlist_dyn',
},
{
content: "check that wishlist contains 2 items and go to wishlist",
extra_trigger: ".label:contains(2)",
trigger: 'a[href="/shop/wishlist"]',
},
{
content: "remove Ipad",
trigger: 'tr:contains("iPad Retina Display") a.o_wish_rm:first',
},
{
content: "check that wishlist contains 1 item",
trigger: ".my_wish_quantity:contains(1)",
run: function() {},
},
{
content: "check B2B wishlist mode",
trigger: "input#b2b_wish",
},
{
content: "add item to cart",
trigger: 'a.o_wish_add:first',
},
{
content: "check that cart contains 1 item",
trigger: ".my_cart_quantity:contains(1)",
run: function() {},
},
{
content: "check that wishlist contains 1 item",
trigger: ".my_wish_quantity:contains(1)",
run: function() {},
},
{
content: "remove B2B wishlist mode",
trigger: "input#b2b_wish",
},
{
content: "add last item to cart",
trigger: 'a.o_wish_add:first',
},
{
content: "check that user is redirect - wishlist is empty",
trigger: "h2:contains('Shopping Cart')",
run: function() {},
},
{
content: "check that cart contains 2 items",
trigger: ".my_cart_quantity:contains(2)",
run: function() {},
},
{
content: "check that wishlist is empty and no more visible",
trigger: ":not(:has(.my_wish_quantity:visible))",
run: function() {},
},
]
);
});

View File

@ -3,11 +3,9 @@ flectra.define('website_sale_wishlist.wishlist', function (require) {
require('web.dom_ready');
var ajax = require('web.ajax');
var rpc = require('web.rpc');
var Widget = require('web.Widget');
var base = require('web_editor.base');
var website_sale_utils = require('website_sale.utils');
var weContext = require('web_editor.context');
if(!$('.oe_website_sale').length) {
return $.Deferred().reject("DOM doesn't contain '.oe_website_sale'");
@ -71,7 +69,7 @@ var ProductWishlist = Widget.extend({
});
},
add_new_products:function($el, e){
add_new_products: function($el, e){
var self = this;
var product_id = parseInt($el.data('product-product-id'), 10);
if (!product_id && e.currentTarget.classList.contains('o_add_wishlist_dyn')) {
@ -112,14 +110,9 @@ var ProductWishlist = Widget.extend({
var product = tr.data('product-id');
var self = this;
rpc.query({
model: 'product.wishlist',
method: 'write',
args: [[wish], { active: false }, weContext.getExtra()],
})
.then(function(){
$(tr).hide();
});
ajax.jsonRpc('/shop/wishlist/remove/' + wish).done(function () {
$(tr).hide();
});
this.wishlist_product_ids = _.without(this.wishlist_product_ids, product);
if (this.wishlist_product_ids.length === 0) {

View File

@ -0,0 +1 @@
from . import test_wishlist_process

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo,Flectra. See LICENSE file for full copyright and licensing details.
import flectra.tests
@flectra.tests.common.at_install(False)
@flectra.tests.common.post_install(True)
class TestUi(flectra.tests.HttpCase):
def test_01_wishlist_tour(self):
self.phantom_js("/", "flectra.__DEBUG__.services['web_tour.tour'].run('shop_wishlist')", "flectra.__DEBUG__.services['web_tour.tour'].tours.shop_wishlist.ready")

View File

@ -5,6 +5,7 @@
<xpath expr="." position="inside">
<link type="text/less" rel='stylesheet' href='/website_sale_wishlist/static/src/less/website_sale_wishlist.less'/>
<script type="text/javascript" src="/website_sale_wishlist/static/src/js/website_sale_wishlist.js"></script>
<script type="text/javascript" src="/website_sale_wishlist/static/src/js/website_sale_tour_wishlist.js"></script>
</xpath>
</template>