summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfja-odoo <fja@odoo.com>2019-06-14 09:17:07 +0000
committerqsm-odoo <qsm@odoo.com>2019-08-05 13:03:52 +0000
commitb6a28a554528a760ceea68eb53c3691a4046862c (patch)
tree2949944479c79ac7b58883afc0818501d32dea9c
parenteac0785f69d0014a8ee708ce1e6a7acf805dde58 (diff)
[REF] website_sale, *: use website_url on product href
* = website_event_sale, website_sale_comparison, website_sale_wishlist Some product links were not using website_url, now that we have an url for product.product we should use that one to reach the right product. Part of https://github.com/odoo/odoo/pull/34149 task-2007400
-rw-r--r--addons/website_event_sale/views/event_templates.xml2
-rw-r--r--addons/website_sale/controllers/main.py2
-rw-r--r--addons/website_sale/models/product.py3
-rw-r--r--addons/website_sale/views/templates.xml12
-rw-r--r--addons/website_sale_comparison/views/website_sale_comparison_template.xml6
-rw-r--r--addons/website_sale_wishlist/views/website_sale_wishlist_template.xml4
6 files changed, 15 insertions, 14 deletions
diff --git a/addons/website_event_sale/views/event_templates.xml b/addons/website_event_sale/views/event_templates.xml
index c43cd83e6ac..3541011ca90 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 93605643fd3..f6f6803760c 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 d8b22e6dfc9..f50336eb381 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 0e32d3c58c9..ae50d527f21 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']&gt;1 else None))" />
+ <t t-set="product_href" t-value="keep(product.website_url, page=(pager['page']['num'] if pager['page']['num']&gt;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 9eb1d4da7df..15dd18b4c2e 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) &gt; 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 e6f95956448..6c81fdb70ef 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>