muestra un extracto de la descripción en las listas de productos.
This commit is contained in:
parent
f0b77967b3
commit
7b4457102e
8 changed files with 101 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
|||
from . import website_snippet_filter
|
||||
from . import product_template
|
|
@ -0,0 +1,19 @@
|
|||
from odoo import models, fields, api
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
website_description_limited = fields.Text(
|
||||
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 = ''
|
|
@ -0,0 +1,44 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue