deja de usar website_description_limited porque javascript de

website_description ya lo recorta.
This commit is contained in:
snt 2024-09-07 02:48:00 +02:00
parent 7aa800adc4
commit 4bb1d4b4a1
9 changed files with 23 additions and 89 deletions

View file

@ -1,9 +1,9 @@
.custom_website_description { .custom_website_description {
font-size: 20px; font-size: 18px;
color: #333; color: #333;
line-height: 1.5; line-height: 1.5;
padding: 15px; padding: 15px;
background-color: #f9f9f9; background-color: #efefff;
border: 1px solid #ddd; border: 1px solid #99c;
border-radius: 12px; border-radius: 12px;
} }

View file

@ -3,7 +3,7 @@
<template id="product_full_description_inherit" inherit_id="website_sale.product"> <template id="product_full_description_inherit" inherit_id="website_sale.product">
<xpath expr="//div[@t-field='product.website_description']" position="replace"> <xpath expr="//div[@t-field='product.website_description']" position="replace">
<div id="product_description" class="oe_structure oe_empty mt16 custom_website_description" <div id="product_description" class="oe_structure oe_empty mt16 custom_website_description"
data-oe-type="html" data-oe-expressioni="product.website_description" data-oe-type="html" data-oe-expression="product.website_description"
> >
<t t-out="product.website_description"/> <t t-out="product.website_description"/>
</div> </div>

View file

@ -1 +0,0 @@
from . import models

View file

@ -8,9 +8,9 @@
"installable": True, "installable": True,
"depends": ["website_sale"], "depends": ["website_sale"],
"data": ["data/snippet_filter_data.xml", "views/website_sale_views.xml"], "data": ["data/snippet_filter_data.xml", "views/website_sale_views.xml"],
'assets': { "assets": {
'web.assets_frontend': [ "web.assets_frontend": [
'website_sale_product_description_displayed/static/src/scss/custom.scss', "website_sale_product_description_displayed/static/src/scss/custom.scss",
], ],
}, }
} }

View file

@ -1,2 +0,0 @@
from . import website_snippet_filter
from . import product_template

View file

@ -1,19 +0,0 @@
from odoo import models, fields, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
website_description_limited = fields.Html(
compute='_compute_website_description_limited',
string='Website Description Limited'
)
@api.depends('website_description')
def _compute_website_description_limited(self):
for product in self:
if product.website_description:
product.website_description_limited = product.website_description.splitlines()[0]
if len(product.website_description_limited) > 240:
product.website_description_limited = product.website_description_limited[:240] + '...'
else:
product.website_description_limited = ''

View file

@ -1,44 +0,0 @@
from odoo import models
class WebsiteSnippetFilter(models.Model):
_inherit = "website.snippet.filter"
def _get_products_latest_sold(self, website, limit, domain, context):
products = super()._get_products_latest_sold(website, limit, domain, context)
if products:
return products.with_context(display_website_description=True)
else:
return products
def _get_products_latest_viewed(self, website, limit, domain, context):
products = super()._get_products_latest_viewed(website, limit, domain, context)
if products:
return products.with_context(display_website_description=True)
else:
return products
def _get_products_recently_sold_with(self, website, limit, domain, context):
products = super()._get_products_recently_sold_with(
website, limit, domain, context
)
if products:
return products.with_context(display_website_description=True)
else:
return products
def _get_products_accessories(self, website, limit, domain, context):
products = super()._get_products_accessories(website, limit, domain, context)
if products:
return products.with_context(display_website_description=True)
else:
return products
def _get_products_alternative_products(self, website, limit, domain, context):
products = super()._get_products_alternative_products(
website, limit, domain, context
)
if products:
return products.with_context(display_website_description=True)
else:
return products

View file

@ -1,9 +1,9 @@
.custom_website_description_excerpt { .custom_website_description_excerpt {
font-size: 15px; font-size: 16px;
color: #333; color: #444;
line-height: 1.5; line-height: 1.0;
padding: 4px; padding: 4px;
background-color: #f9f9f9; background-color: #f6f6ff;
border: 1px solid #ddd; border: 1px solid #99d;
border-radius: 12px; border-radius: 8px;
} }

View file

@ -3,18 +3,18 @@
<template <template
id="products_item" id="products_item"
name="Display product description" name="Display product description"
inherit_id="website_sale.products_item" inherit_id="website_sale.products_description"
customize_show="True" customize_show="True"
> >
<xpath expr="//a[@t-field='product.name']" position="after"> <xpath expr="//div[@t-field='product.description_sale']" position="replace">
<div class="product-desription custom_website_description_excerpt" > <div class="oe_structure oe_empty custom_website_description_excerpt" >
<b><div t-if="product.autor">Autor: <t t-out="product.autor" /></div> <span t-if="product.autor"><b><t t-out="product.autor" /></b></span>
<div t-if="product.editorial">Editora: <t t-out="product.editorial" /></div> <span t-if="product.genero" class="text-muted small"> (<t t-out="product.genero" />)</span>
<div t-if="product.genero"><t t-out="product.genero" /></div></b> <span t-if="product.formato" class="text-muted small"><t t-out="product.formato" /></span>
<div t-if="product.website_description_limited" class="oe_structure oe_empty custom_website_description_excerpt" data-oe-type="html" data-oe-expressioni="product.website_description"> <div t-if="product.website_description">
<p><t t-out="product.website_description_limited"/></p> <t t-out="product.website_description"/>
</div> </div>
</div> </div>
</xpath> </xpath>
</template> </template>
</odoo> </odoo>