Skip to content

Commit

Permalink
[16.0][MIG]website_sale_product_minimal_price: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiosca-s73 committed Oct 17, 2023
1 parent 5ba23ff commit ff8ead2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 62 deletions.
6 changes: 6 additions & 0 deletions setup/website_sale_product_minimal_price/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
12 changes: 4 additions & 8 deletions website_sale_product_minimal_price/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Website Sale Product Minimal Price",
"summary": "Display minimal price for products that has variants",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"development_status": "Production/Stable",
"maintainers": ["sergio-teruel"],
"category": "Website",
Expand All @@ -17,15 +17,11 @@
"assets": {
"web.assets_frontend": [
"/web/static/src/legacy/js/fields/field_utils.js",
"/website_sale_product_minimal_price/static/src/js"
"/website_sale_product_minimal_price.js",
"/website_sale_product_minimal_price/static/src/js"
"/website_sale_product_price_scale.js",
"/website_sale_product_minimal_price/static/src/xml/*.xml",
"/website_sale_product_minimal_price/static/src/js/*.js",
],
"web.assets_tests": [
"/website_sale_product_minimal_price/static/src/js/tour.js",
"/website_sale_product_minimal_price/static/src/js"
"/test_product_with_no_prices_tour.js",
"/website_sale_product_minimal_price/static/src/js/tours/*.js"
],
},
}
4 changes: 2 additions & 2 deletions website_sale_product_minimal_price/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def get_combination_info_pricelist_atributes(self, product_id, **kwargs):
)
qty_list = sorted(set(qty_list.mapped("min_quantity")))
res = []
last_price = product.with_context(quantity=0).price
last_price = product.with_context(quantity=0)._get_contextual_price()
for min_qty in qty_list:
new_price = product.with_context(quantity=min_qty).price
new_price = product.with_context(quantity=min_qty)._get_contextual_price()
if new_price != last_price:
res.append(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _get_cheapest_info(self, pricelist):
for qty in [1, 99999999]:
product_price = product.with_context(
quantity=qty, pricelist=pricelist.id
).price
)._get_contextual_price()
if product_price != min_price and min_price != 99999999:
# Mark if there are different prices iterating over
# variants and comparing qty 1 and maximum qty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ odoo.define("website_sale_product_minimal_price.shop_min_price", function (requi

publicWidget.registry.WebsiteSaleProductMinimalPrice = publicWidget.Widget.extend({
selector: "#products_grid",
xmlDependencies: [
"/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml",
],

start: function () {
return Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ odoo.define("website_sale_product_minimal_price.load", function (require) {
const publicWidget = require("web.public.widget");
const VariantMixin = require("sale.VariantMixin");
const QWeb = core.qweb;
const load_xml = async () => {
return ajax.loadXML(
"/website_sale_product_minimal_price/static/src/xml/" +
"website_sale_product_price_scale.xml",
QWeb
);
};

require("website_sale.website_sale");

Expand All @@ -27,49 +20,44 @@ odoo.define("website_sale_product_minimal_price.load", function (require) {
const uom_name = vals[1];
$(".temporal").remove();
if (unit_prices.length > 0) {
load_xml().then(function () {
const $form = $('form[action*="/shop/cart/update"]');
$form.append('<hr class="temporal"/>');
$form.append(
QWeb.render("website_sale_product_minimal_price.title", {
uom: uom_name,
})
);
// We define a limit of displayed columns as 4
const limit_col = 4;
let $div; // eslint-disable-line init-declarations
for (const i in unit_prices) {
if (unit_prices[i].price === 0) {
continue;
}
if (i % limit_col === 0) {
const id = i / limit_col;
$form.append(
'<div id="row_' + id + '" class="row temporal"></div>'
);
$div = $("#row_" + id);
}
let monetary_u = field_utils.format.monetary(
unit_prices[i].price,
{},
{currency: unit_prices[i].currency}
);
monetary_u = monetary_u.replace("&nbsp;", " ");
$div.append(
QWeb.render(
"website_sale_product_minimal_price.pricelist",
{
quantity: unit_prices[i].min_qty,
price: monetary_u,
}
)
);
const $form = $('form[action*="/shop/cart/update"]');
$form.append('<hr class="temporal"/>');
$form.append(
QWeb.render("website_sale_product_minimal_price.title", {
uom: uom_name,
})
);
// We define a limit of displayed columns as 4
const limit_col = 4;
let $div; // eslint-disable-line init-declarations
for (const i in unit_prices) {
if (unit_prices[i].price === 0) {
continue;
}
$div = $('div[id*="row_"]');
for (let i = 0; i < $div.length - 1; i++) {
$($div[i]).addClass("border-bottom");
if (i % limit_col === 0) {
const id = i / limit_col;
$form.append(
'<div id="row_' + id + '" class="row temporal"></div>'
);
$div = $("#row_" + id);
}
});
let monetary_u = field_utils.format.monetary(
unit_prices[i].price,
{},
{currency: unit_prices[i].currency}
);
monetary_u = monetary_u.replace("&nbsp;", " ");
$div.append(
QWeb.render("website_sale_product_minimal_price.pricelist", {
quantity: unit_prices[i].min_qty,
price: monetary_u,
})
);
}
$div = $('div[id*="row_"]');
for (let i = 0; i < $div.length - 1; i++) {
$($div[i]).addClass("border-bottom");
}
}
});
};
Expand Down

0 comments on commit ff8ead2

Please sign in to comment.