39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
# Copyright (C) 2021-2024: Criptomart (https://criptomart.net)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from odoo import tools, models, fields, api, _
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = "product.template"
|
|
|
|
subtitle = fields.Char('Subtitulo')
|
|
editorial = fields.Char('Editorial')
|
|
formato = fields.Char('Formato')
|
|
pais_edicion = fields.Char('Pais de edicion')
|
|
colacion = fields.Char('Colacion')
|
|
autor = fields.Char('Autor')
|
|
coleccion = fields.Char('Coleccion')
|
|
subcoleccion = fields.Char('Subcoleccion')
|
|
idioma = fields.Char('Idioma')
|
|
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/"
|