diff --git a/addons/website_event_sale/views/event_templates.xml b/addons/website_event_sale/views/event_templates.xml index c43cd83e6ac6545dc2132f8397a812dc4331ed5b..3541011ca902f66087e48909015ebc389254ad7f 100644 --- a/addons/website_event_sale/views/event_templates.xml +++ b/addons/website_event_sale/views/event_templates.xml @@ -89,7 +89,7 @@ <xpath expr="//a" position="attributes"> <attribute name="t-attf-href"/> <attribute name="t-att-href"> - line.event_id and ('/event/%s/register' % slug(line.event_id)) or ('/shop/product/%s' % slug(line.product_id.product_tmpl_id)) + line.event_id and ('/event/%s/register' % slug(line.event_id)) or line.product_id.website_url </attribute> </xpath> </template> diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 93605643fd335b8280a394f97997abe7941870a7..f6f6803760cf0364449db384e768187237f800ef 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -1069,7 +1069,7 @@ class WebsiteSale(http.Controller): 'public_categ_ids': category, 'website_id': request.website.id, }) - return "/shop/product/%s?enable_editor=1" % slug(product.product_tmpl_id) + return "%s?enable_editor=1" % product.product_tmpl_id.website_url @http.route(['/shop/change_styles'], type='json', auth='user') def change_styles(self, id, style_id): diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index d8b22e6dfc91397cb05e325d02dbab986b8ded1b..f50336eb3810d7a58c9fdba0fd1ed99b055a4d57 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, _ from odoo.exceptions import ValidationError, UserError +from odoo.addons.http_routing.models.ir_http import slug from odoo.addons.website.models import ir_http from odoo.tools.translate import html_translate from odoo.osv import expression @@ -367,7 +368,7 @@ class ProductTemplate(models.Model): def _compute_website_url(self): super(ProductTemplate, self)._compute_website_url() for product in self: - product.website_url = "/shop/product/%s" % (product.id,) + product.website_url = "/shop/product/%s" % slug(product) # --------------------------------------------------------- # Rating Mixin API diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 0e32d3c58c9b261b857ea0205801ff1fd71eaf4e..ae50d527f2181e5193e978e6f7639d99a40f5a10 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -132,7 +132,7 @@ </template> <template id="products_item" name="Products item"> - <t t-set="product_href" t-value="request.httprequest.url_root + keep('shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))" /> + <t t-set="product_href" t-value="keep(product.website_url, page=(pager['page']['num'] if pager['page']['num']>1 else None))" /> <t t-set="combination_info" t-value="product._get_combination_info(only_template=True, add_qty=add_qty or 1, pricelist=pricelist)"/> @@ -499,7 +499,7 @@ </div> <div class="col-md-6 col-xl-4" id="product_details"> <h1 itemprop="name" t-field="product.name">Product Name</h1> - <span itemprop="url" style="display:none;" t-esc="'%sshop/product/%s' % (request.httprequest.url_root, slug(product))"/> + <span itemprop="url" style="display:none;" t-esc="product.website_url"/> <form t-if="product._is_add_to_cart_possible()" action="/shop/cart/update" method="POST"> <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" /> <div class="js_product js_main_product"> @@ -576,7 +576,7 @@ <div t-if="product_variant" t-field="product_variant.image_64" t-options="{'widget': 'image', 'class': 'rounded shadow o_alternative_product' }" /> <div t-else="" t-field="alt_product.image_64" t-options="{'widget': 'image', 'class': 'rounded shadow o_alternative_product' }" /> <h6> - <a t-attf-href="/shop/product/#{ slug(alt_product) }" style="display: block"> + <a t-att-href="alt_product.website_url" style="display: block"> <span t-att-title="alt_product.name" t-field="alt_product.name" class="o_text_overflow" style="display: block;" /> </a> </h6> @@ -802,7 +802,7 @@ <!-- We use this template where we want to give the user a link to the product of a sale order line. --> <template id="cart_line_product_link" name="Shopping Cart Line Product Link"> - <a t-attf-href="/shop/product/#{ slug(line.product_id.product_tmpl_id) }"> + <a t-att-href="line.product_id.website_url"> <t t-raw="0"/> </a> </template> @@ -994,13 +994,13 @@ <tr t-foreach="suggested_products" t-as="product"> <t t-set="combination_info" t-value="product._get_combination_info_variant()"/> <td class='td-img'> - <a t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }"> + <a t-att-href="product.website_url"> <span t-field="product.image_64" t-options="{'widget': 'image', 'class': 'rounded'}" /> </a> </td> <td class='td-product_name'> <div> - <a t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }"> + <a t-att-href="product.website_url"> <strong t-esc="combination_info['display_name']" /> </a> </div> diff --git a/addons/website_sale_comparison/views/website_sale_comparison_template.xml b/addons/website_sale_comparison/views/website_sale_comparison_template.xml index 9eb1d4da7df94357ae57830f1bfc3c4e02d99bb6..15dd18b4c2e2a8a11f2601a3f3618ef36d2f949b 100644 --- a/addons/website_sale_comparison/views/website_sale_comparison_template.xml +++ b/addons/website_sale_comparison/views/website_sale_comparison_template.xml @@ -96,11 +96,11 @@ <a href="#" t-att-data-product_product_id="product.id" class="o_comparelist_remove" t-if="len(products) > 2"> <strong class='float-right'>x</strong> </a> - <a t-att-href="'/shop/product/%s' % slug(product.product_tmpl_id)"> + <a t-att-href="product.website_url"> <img t-attf-src="/web/image/product.product/#{product.id}/image_256" class="img img-fluid" style="margin:auto;" alt="Product image"/> </a> <div class='product_summary'> - <a class="o_product_comparison_table" t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }"> + <a class="o_product_comparison_table" t-att-href="product.website_url"> <span t-esc="combination_info['display_name']"></span><br/> </a> @@ -147,7 +147,7 @@ </div> <div class="col-8 pl-2"> <h6> - <a t-attf-href="/shop/product/#{product.product_tmpl_id[0].id}"><t t-esc="combination_info['display_name']" /></a><br/> + <a t-att-href="product.website_url"><t t-esc="combination_info['display_name']" /></a><br/> <t t-if="True"><!--compatibility 12.0--> <del t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="white-space: nowrap;" t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" /> </t> diff --git a/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml b/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml index e6f95956448417320a020116b3a66d21ee5a9b1b..6c81fdb70efa3416f7cb0d33155fe171e8a87b2c 100644 --- a/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml +++ b/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml @@ -62,12 +62,12 @@ <t t-foreach="wishes" t-as="wish"> <tr t-att-data-wish-id='wish.id' t-att-data-product-id='wish.product_id.id'> <td class='td-img'> - <a t-att-href="'/shop/product/%s' % slug(wish.product_id.product_tmpl_id)"> + <a t-att-href="wish.product_id.website_url"> <img t-attf-src="/web/image/product.product/#{wish.product_id.id}/image_128" class="img img-fluid" style="margin:auto;" alt="Product image"/> </a> </td> <td class='text-left'> - <strong><a t-att-href="'/shop/product/%s' % slug(wish.product_id.product_tmpl_id)"><t t-esc="wish.product_id.display_name" /></a></strong> + <strong><a t-att-href="wish.product_id.website_url"><t t-esc="wish.product_id.display_name" /></a></strong> <small class='d-none d-md-block'><p t-field="wish.product_id.description_sale" class="text-muted"/></small> <button type="button" class="btn btn-link o_wish_rm no-decoration"><small><i class='fa fa-trash-o'></i> Remove</small></button> </td>