From cd54429cf879c7f68be6f03d668c039532f037c9 Mon Sep 17 00:00:00 2001 From: snt Date: Sun, 29 Mar 2026 16:50:00 +0200 Subject: [PATCH] Add multimedia URL field and website audio iframe embeds --- product_library/models/product_template.py | 19 +++++++++++ product_library/views/product.xml | 1 + .../models/product_template.py | 8 +++-- .../static/src/scss/custom.scss | 34 +++++++++++++++++++ .../views/website_sale_views.xml | 18 ++++++++++ 5 files changed, 78 insertions(+), 2 deletions(-) diff --git a/product_library/models/product_template.py b/product_library/models/product_template.py index bb66747..1782496 100644 --- a/product_library/models/product_template.py +++ b/product_library/models/product_template.py @@ -18,3 +18,22 @@ class ProductTemplate(models.Model): fecha_entrada = fields.Char('Fecha de entrada') fecha_edicion = fields.Char('Fecha de edición') genero = fields.Char('Genero') + multimedia_url = fields.Char('URL multimedia') + multimedia_embed_url = fields.Char( + string='URL multimedia embebida', + compute='_compute_multimedia_embed_url', + ) + + @api.depends('multimedia_url') + def _compute_multimedia_embed_url(self): + for record in self: + url = (record.multimedia_url or '').strip() + if not url: + record.multimedia_embed_url = False + continue + + base_url = url.rstrip('/') + if base_url.endswith('/embed/all'): + record.multimedia_embed_url = f"{base_url}/" + else: + record.multimedia_embed_url = f"{base_url}/embed/all/" diff --git a/product_library/views/product.xml b/product_library/views/product.xml index ec51e0a..6764601 100644 --- a/product_library/views/product.xml +++ b/product_library/views/product.xml @@ -18,6 +18,7 @@ + diff --git a/website_sale_product_library/models/product_template.py b/website_sale_product_library/models/product_template.py index 8a87056..48722cb 100644 --- a/website_sale_product_library/models/product_template.py +++ b/website_sale_product_library/models/product_template.py @@ -1,4 +1,6 @@ -from odoo import api, models, fields +from odoo import api, models + + class ProductTemplate(models.Model): _inherit = 'product.template' @@ -12,6 +14,8 @@ class ProductTemplate(models.Model): search_details['fetch_fields'].append('editorial') search_details['search_fields'].append('subtitle') search_details['fetch_fields'].append('subtitle') + search_details['fetch_fields'].append('multimedia_url') + search_details['fetch_fields'].append('multimedia_embed_url') search_details['search_fields'].remove('description') search_details['search_fields'].remove('description_sale') - return search_details \ No newline at end of file + return search_details diff --git a/website_sale_product_library/static/src/scss/custom.scss b/website_sale_product_library/static/src/scss/custom.scss index 9006749..0bd14b5 100644 --- a/website_sale_product_library/static/src/scss/custom.scss +++ b/website_sale_product_library/static/src/scss/custom.scss @@ -7,3 +7,37 @@ border: 1px solid #99d; border-radius: 6px; } + +.oe_product_cart { + position: relative; +} + +.o_multimedia_hover_player { + position: absolute; + left: 0; + right: 0; + bottom: 0.75rem; + z-index: 4; + opacity: 0; + pointer-events: none; + transition: opacity 0.2s ease-in-out; + padding: 0 0.5rem; +} + +.oe_product_cart .o_wsale_product_grid_wrapper:hover + .o_multimedia_hover_player, +.oe_product_cart .o_multimedia_hover_player:hover { + opacity: 1; + pointer-events: auto; +} + +.o_multimedia_hover_player iframe, +.o_multimedia_product_player iframe { + width: 100%; + min-width: 0; +} + +@media (max-width: 991.98px) { + .o_multimedia_hover_player { + display: none !important; + } +} diff --git a/website_sale_product_library/views/website_sale_views.xml b/website_sale_product_library/views/website_sale_views.xml index 20d1f96..a843d6c 100644 --- a/website_sale_product_library/views/website_sale_views.xml +++ b/website_sale_product_library/views/website_sale_views.xml @@ -13,6 +13,16 @@ + +
+