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
1
website_sale_product_description_displayed/__init__.py
Normal file
1
website_sale_product_description_displayed/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from . import models
|
11
website_sale_product_description_displayed/__manifest__.py
Normal file
11
website_sale_product_description_displayed/__manifest__.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "Display product website descrition in e-commerce catalog pages.",
|
||||
"version": "16.0.1.0.2",
|
||||
"category": "Website",
|
||||
"author": "Criptomart",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": ["website_sale"],
|
||||
"data": ["data/snippet_filter_data.xml", "views/website_sale_views.xml"],
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="website_sale.dynamic_snippet_newest_products_filter" model="ir.filters">
|
||||
<field
|
||||
name="context"
|
||||
>{'display_website_description': True, 'add2cart_rerender': False}</field>
|
||||
</record>
|
||||
</odoo>
|
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template
|
||||
id="products_item"
|
||||
name="Display product description"
|
||||
inherit_id="website_sale.products_item"
|
||||
customize_show="True"
|
||||
>
|
||||
<xpath expr="//a[@t-field='product.name']" position="after">
|
||||
<div t-if="product.website_description_limited" class="product-website-description">
|
||||
<t t-raw="product.website_description_limited"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
Loading…
Add table
Reference in a new issue