Skip to content

Commit

Permalink
[MIG] website_sale_product_minimal_price: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edward_yoch committed Jun 24, 2024
1 parent a9dfe55 commit 615949a
Show file tree
Hide file tree
Showing 22 changed files with 298 additions and 359 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ env:

# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
parserOptions:
ecmaVersion: 2019
ecmaVersion: 2021
sourceType: "module"

overrides:
- files:
Expand Down
10 changes: 5 additions & 5 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": "16.0.1.0.0",
"version": "17.0.1.0.0",
"development_status": "Production/Stable",
"maintainers": ["sergio-teruel"],
"category": "Website",
Expand All @@ -12,13 +12,13 @@
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["website_sale"],
"depends": ["web", "website_sale"],
"data": ["views/templates.xml"],
"assets": {
"web.assets_frontend": [
"/web/static/src/legacy/js/fields/field_utils.js",
"/website_sale_product_minimal_price/static/src/xml/*.xml",
"/website_sale_product_minimal_price/static/src/js/*.js",
"web/static/src/views/fields/formatters.js",
"website_sale_product_minimal_price/static/src/xml/website_sale_product_price_scale.xml",
"website_sale_product_minimal_price/static/src/js/website_sale_product_price_scale.js",
],
"web.assets_tests": [
"/website_sale_product_minimal_price/static/src/js/tours/*.js"
Expand Down
82 changes: 15 additions & 67 deletions website_sale_product_minimal_price/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,12 @@
from odoo import http
from odoo.http import request

from odoo.addons.sale.controllers.variant import VariantController
from odoo.addons.website_sale.controllers.variant import WebsiteSaleVariantController


class WebsiteSaleVariantController(VariantController):
class WebsiteSaleVariantController(WebsiteSaleVariantController):
@http.route(
["/sale/get_combination_info_minimal_price"],
type="json",
auth="public",
methods=["POST"],
website=True,
)
def get_combination_info_minimal_price(self, product_template_ids, **kw):
"""Special route to use website logic in get_combination_info override.
This route is called in JS by appending _website to the base route.
"""
res = []
templates = request.env["product.template"].sudo().browse(product_template_ids)
pricelist = request.env["website"].get_current_website().get_current_pricelist()
for template in templates.filtered(lambda t: t.is_published):
product_id, add_qty, has_distinct_price = template._get_cheapest_info(
pricelist
)
combination = template._get_combination_info(
product_id=product_id, add_qty=add_qty, pricelist=pricelist
)
res.append(
{
"id": template.id,
"price": combination.get("price"),
"distinct_prices": has_distinct_price,
"currency": {
"position": template.currency_id.position,
"symbol": template.currency_id.symbol,
},
}
)
return res

@http.route(
["/sale/get_combination_info_pricelist_atributes"],
["/website_sale/get_combination_info_pricelist_atributes"],
type="json",
auth="public",
website=True,
Expand All @@ -52,7 +18,15 @@ def get_combination_info_pricelist_atributes(self, product_id, **kwargs):
"""Special route to use website logic in get_combination_info override.
This route is called in JS by appending _website to the base route.
"""
pricelist = request.env["website"].get_current_website().get_current_pricelist()
# Copied from _get_combination_info
# /odoo/addons/website_sale/models/product_template.py
website = (
# pylint: disable=W8121
request.env["website"]
.get_current_website()
.with_context(request.env.context)
)
pricelist = website.pricelist_id
product = (
request.env["product.product"]
.browse(product_id)
Expand All @@ -61,34 +35,8 @@ def get_combination_info_pricelist_atributes(self, product_id, **kwargs):
# Getting all min_quantity of the current product to compute the possible
# price scale.
qty_list = request.env["product.pricelist.item"].search(
[
"|",
("product_id", "=", product.id),
"|",
("product_tmpl_id", "=", product.product_tmpl_id.id),
(
"categ_id",
"in",
list(map(int, product.categ_id.parent_path.split("/")[0:-1])),
),
("min_quantity", ">", 0),
]
product._get_product_pricelist_item_domain()
)
qty_list = sorted(set(qty_list.mapped("min_quantity")))
res = []
last_price = product.with_context(quantity=0)._get_contextual_price()
for min_qty in qty_list:
new_price = product.with_context(quantity=min_qty)._get_contextual_price()
if new_price != last_price:
res.append(
{
"min_qty": min_qty,
"price": new_price,
"currency": {
"position": product.currency_id.position,
"symbol": product.currency_id.symbol,
},
}
)
last_price = new_price
return (res, product.uom_name)

return product._get_product_price_scale(qty_list)
12 changes: 6 additions & 6 deletions website_sale_product_minimal_price/i18n/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-17 14:53+0000\n"
"PO-Revision-Date: 2021-05-17 16:54+0200\n"
Expand All @@ -18,9 +18,7 @@ msgstr ""
"X-Generator: Poedit 2.0.6\n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr "De"

Expand All @@ -36,5 +34,7 @@ msgstr "Preus per quantitat ("
msgid "Product"
msgstr ""

#~ msgid "Product Template"
#~ msgstr "Plantilla de producte"
#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""
12 changes: 6 additions & 6 deletions website_sale_product_minimal_price/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0+e\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-17 14:53+0000\n"
"PO-Revision-Date: 2021-05-17 16:54+0200\n"
Expand All @@ -18,9 +18,7 @@ msgstr ""
"X-Generator: Poedit 2.0.6\n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr "Desde"

Expand All @@ -36,5 +34,7 @@ msgstr "Precios por cantidad ("
msgid "Product"
msgstr ""

#~ msgid "Product Template"
#~ msgstr "Plantilla de producto"
#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""
12 changes: 6 additions & 6 deletions website_sale_product_minimal_price/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-09-03 13:35+0000\n"
"Last-Translator: benj-filament <benjamin@le-filament.com>\n"
Expand All @@ -17,9 +17,7 @@ msgstr ""
"X-Generator: Weblate 4.17\n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr "À partir de"

Expand All @@ -35,5 +33,7 @@ msgstr "Prix par quantité ("
msgid "Product"
msgstr ""

#~ msgid "Product Template"
#~ msgstr "Modèle d'article"
#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""
13 changes: 8 additions & 5 deletions website_sale_product_minimal_price/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-08 16:34+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
Expand All @@ -17,9 +17,7 @@ msgstr ""
"X-Generator: Weblate 4.17\n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr "Dal"

Expand All @@ -33,4 +31,9 @@ msgstr "Prezzi per quantità ("
#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_template
msgid "Product"
msgstr "Prodotto"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""
14 changes: 7 additions & 7 deletions website_sale_product_minimal_price/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-17 14:53+0000\n"
"PO-Revision-Date: 2021-05-17 16:55+0200\n"
Expand All @@ -18,9 +18,7 @@ msgstr ""
"X-Generator: Poedit 2.0.6\n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr "Van"

Expand All @@ -29,12 +27,14 @@ msgstr "Van"
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_price_scale.xml:0
#, python-format
msgid "Prices per quantity ("
msgstr ""
msgstr "Prijzen per hoeveelheid ("

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_template
msgid "Product"
msgstr ""

#~ msgid "Product Template"
#~ msgstr "Product Sjabloon"
#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""
25 changes: 8 additions & 17 deletions website_sale_product_minimal_price/i18n/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-08-22 14:07+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n"
Expand All @@ -17,11 +17,9 @@ msgstr ""
"X-Generator: Weblate 4.3.2\n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr "A partir de"
msgstr "A partir d"

#. module: website_sale_product_minimal_price
#. odoo-javascript
Expand All @@ -30,19 +28,12 @@ msgstr "A partir de"
msgid "Prices per quantity ("
msgstr "Preços por quantidade ("

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_template
msgid "Product"
msgstr ""

#~ msgid "Product Template"
#~ msgstr "Modelo de Produto"

#~ msgid "Display Name"
#~ msgstr "Nome a Exibir"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Modific. pela última vez em"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -14,9 +14,7 @@ msgstr ""
"Plural-Forms: \n"

#. module: website_sale_product_minimal_price
#. odoo-javascript
#: code:addons/website_sale_product_minimal_price/static/src/xml/website_sale_product_minimal_price.xml:0
#, python-format
#: model_terms:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "From"
msgstr ""

Expand All @@ -31,3 +29,8 @@ msgstr ""
#: model:ir.model,name:website_sale_product_minimal_price.model_product_template
msgid "Product"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_product
msgid "Product Variant"
msgstr ""
1 change: 1 addition & 0 deletions website_sale_product_minimal_price/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import product_product
from . import product_template
Loading

0 comments on commit 615949a

Please sign in to comment.