Skip to content

Commit

Permalink
[MIG] website_sale_stock_list_preview: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ernesto-garcia-tecnativa committed Aug 28, 2023
1 parent 6c029da commit 9ae49f4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion website_sale_stock_list_preview/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Website Sale Stock List Preview",
"summary": "Show the stock of products on the product previews",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
4 changes: 3 additions & 1 deletion website_sale_stock_list_preview/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def get_combination_info_stock_preview(self, product_template_ids, **kw):
"product_template": template.id,
"product_type": template.type,
"free_qty": sum(variants.mapped("free_qty")),
"cart_qty": sum(variants.mapped("cart_qty")),
"cart_qty": sum(
[product._get_cart_qty(current_website) for product in variants]
),
"out_of_stock_message": template.out_of_stock_message,
"allow_out_of_stock_order": template.allow_out_of_stock_order,
"show_availability": template.show_availability,
Expand Down
2 changes: 0 additions & 2 deletions website_sale_stock_list_preview/static/src/tests/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ odoo.define("website_sale_stock_list_preview.tour", function (require) {
"use strict";

var tour = require("web_tour.tour");
var base = require("web_editor.base");

var steps = [
{
Expand Down Expand Up @@ -119,7 +118,6 @@ odoo.define("website_sale_stock_list_preview.tour", function (require) {
{
url: "/shop",
test: true,
wait_for: base.ready(),
},
steps
);
Expand Down
49 changes: 25 additions & 24 deletions website_sale_stock_list_preview/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

@tagged("post_install", "-at_install")
class UICase(HttpCase):
def setUp(self):
super().setUp()
product1 = self.env["product.template"].create(
@classmethod
def setUpClass(cls):
super().setUpClass()
product1 = cls.env["product.template"].create(
{
"name": "Test Product 1",
"is_published": True,
Expand All @@ -18,7 +19,7 @@ def setUp(self):
"available_threshold": 99999,
}
)
product2 = self.env["product.template"].create(
product2 = cls.env["product.template"].create(
{
"name": "Test Product 2",
"is_published": True,
Expand All @@ -28,7 +29,7 @@ def setUp(self):
"show_availability": True,
}
)
product3 = self.env["product.template"].create(
product3 = cls.env["product.template"].create(
{
"name": "Test Product 3",
"is_published": True,
Expand All @@ -39,7 +40,7 @@ def setUp(self):
"available_threshold": 5,
}
)
self.env["product.template"].create(
cls.env["product.template"].create(
{
"name": "Test Product 4",
"is_published": True,
Expand All @@ -48,15 +49,15 @@ def setUp(self):
"out_of_stock_message": "test message",
}
)
self.env["product.template"].create(
cls.env["product.template"].create(
{
"name": "Test Product 5",
"is_published": True,
"website_sequence": 1,
"type": "product",
}
)
self.env["product.template"].create(
cls.env["product.template"].create(
{
"name": "Test Product 6",
"is_published": True,
Expand All @@ -67,7 +68,7 @@ def setUp(self):
"out_of_stock_message": "Out of stock",
}
)
self.env["product.template"].create(
cls.env["product.template"].create(
{
"name": "Test Product 7",
"is_published": True,
Expand All @@ -77,42 +78,42 @@ def setUp(self):
"show_availability": True,
}
)
self.env["stock.quant"].create(
cls.env["stock.quant"].create(
[
{
"product_id": product1.product_variant_id.id,
"location_id": self.env.ref("stock.stock_location_stock").id,
"location_id": cls.env.ref("stock.stock_location_stock").id,
"quantity": 30.0,
},
{
"product_id": product2.product_variant_id.id,
"location_id": self.env.ref("stock.stock_location_stock").id,
"location_id": cls.env.ref("stock.stock_location_stock").id,
"quantity": 30.0,
},
{
"product_id": product3.product_variant_id.id,
"location_id": self.env.ref("stock.stock_location_stock").id,
"location_id": cls.env.ref("stock.stock_location_stock").id,
"quantity": 5.0,
},
]
)
self.env.ref("website_sale.products_add_to_cart").active = True
cls.env.ref("website_sale.products_add_to_cart").active = True
# Ensure website lang is en_US.
website = self.env["website"].get_current_website()
wiz = self.env["base.language.install"].create({"lang": "en_US"})
website = cls.env["website"].get_current_website()
en_us = (
cls.env["res.lang"]
.with_context(active_test=False)
.search([("code", "=", "en_US")])
)
wiz = cls.env["base.language.install"].create({"lang_ids": en_us.ids})
wiz.website_ids = website
wiz.lang_install()
website.default_lang_id = self.env.ref("base.lang_en")
website.default_lang_id = cls.env.ref("base.lang_en")

def test_ui_website(self):
"""Test frontend tour."""
tour = (
"odoo.__DEBUG__.services['web_tour.tour']",
self.start_tour(
"/shop",
"website_sale_stock_list_preview",
)
self.browser_js(
url_path="/shop",
code="%s.run('%s')" % tour,
ready="%s.tours['%s'].ready" % tour,
login="admin",
)

0 comments on commit 9ae49f4

Please sign in to comment.