Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Creating article in knowledge module, Button and js not being rendered

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
javascriptknowledge
1 Répondre
1778 Vues
Avatar
Collins Matutu

if i use a span tag or a tag its working but if use button in the <td> its not being rendered also when ever i point to any js its not working or rendering. it can be in the script or web_assets_backend nothing is working 
Odoo 17


def create_article_calendar(self):
if not self.product_line_ids:
raise ValidationError("Please add an agenda before making an Article!")

counter = 1
company_id = self.env.company
product_id = self.product_id.id
logo = company_id.logo
if logo:
logo_html = Markup('<img src="%s" class="bg-view" alt="Company Logo"/>') % self._get_src_data_b64(logo)
else:
logo_html = ''

html_content = Markup("""
<table class="table">
<thead>
<tr style="border: 0px; background-color: #ffffff;">
<th style="padding: 10px; border: 0px;">ID</th>
<th style="padding: 10px; border: 0px;">Agenda Item</th>
<th style="padding: 10px; border: 0px;">Presenter</th>
<th style="padding: 10px; border: 0px;">Action</th>
</tr>
</thead>
<tbody id="article_body">
""")

for line in self.product_line_ids:
presenters = ', '.join(presenter.name for presenter in line.presenter_id)
html_content += Markup("""
<tr style="border: 0px;">
<td style="padding: 10px; border: 0px;">{counter}</td>
<td style="padding: 10px; border: 0px;">{description}</td>
<td style="padding: 10px; border: 0px;">{presenters}</td>
<td style="padding: 10px; border: 0px;">
<span type="button" style="display: inline-block; padding: 10px 20px; background-color: #17a2b8; color: #fff; cursor: pointer; border-radius: 5px;"
onclick="triggerAction({counter})"> Attachments </span>
</td>
</tr>
""").format(
counter=counter,
description=line.description or 'N/A',
presenters=presenters or 'N/A'
)
counter += 1

html_content += Markup("""
</tbody>
</table>
<script>
function triggerAction(id) {
console.log("Button clicked with ID: ", id);
alert("Action triggered with ID: " + id);
}
</script>
""")

body_content = Markup("""
<div>
<header style="text-align: center;">
{logo_html}<br><br>
<h2><strong>{company_name}<strong></h2>
</header>
<div class="container">
<div class="card-body border-dark">
<div class="row no-gutters align-items-center">
<div class="col align-items-center">
<p class="mb-0">
<span> {company_street} </span>
</p>
<p class="mb-0">
<span> {company_city} </span>
</p>
<p class="m-0">
<span> {company_country} </span>
</p>
</div>
<div class="col-auto">
<div class="float-right text-end">
<p class="mb-0 float-right">
<span> {company_phone} </span>
<i class="fa fa-phone-square ms-2 text-info" title="Phone"/>
</p>
<p class="mb-0 float-right">
<span> {company_email} </span>
<i class="fa fa-envelope ms-2 text-info" title="Email"/>
</p>
<p class="mb-0 float-right">
<span> {company_website} </span>
<i class="fa fa-globe ms-2 text-info" title="Website"/>
</p>
</div>
</div>
</div>
</div>
</div><br><hr>
<div class="container">
<p><strong style='font-size: 14px;'>Title: </strong> {event_name}</p>
<p><strong>Start Date:</strong> {start_date}</p>
<p><strong>Organizer:</strong> {organizer}</p>
<p><strong>Subject:</strong> {description}</p>
</div>
<hr/>
{html_content}
</div>
""").format(
logo_html=logo_html,
company_name=company_id.name,
company_street=company_id.street,
company_city=company_id.city,
company_country=company_id.country_id.name,
company_phone=company_id.phone,
company_email=company_id.email,
company_website=company_id.website,
event_name=self.name,
start_date=self.start_date or ' ',
organizer=self.user_id.name,
description=self.description,
html_content=html_content
)

# Log the generated HTML for debugging
_logger.info("Generated HTML content for the article: %s", body_content)

article_values = {
'name': Markup("Agenda: {event_name}").format(event_name=self.name),
'body': body_content,
'calendar_id': self.id,
}

article = self.env['knowledge.article'].sudo().create(article_values)
self.article_id = article.id

self.article_id.product_id = self.product_id.id
self.last_write_count = len(self.product_line_ids)
self.last_write_date = fields.Datetime.now()
0
Avatar
Ignorer
Avatar
Julien Banken (jbn)
Meilleure réponse

Hello,

By default, Odoo will scrap all the script tags present in the HTML fields to prevent script injection. If we don't discard the tags, someone could edit an article and insert a malicious script that could, for instance, steal the session cookies of a user (see: XSS attack).

If you want to have a dynamic component in your article, you will need to create a "Behavior". You can maybe check different examples in the codebase?

For your issue with the buttons not being rendered inside a `<td>` element, that's weird. I think it should be valid. Are you sure your HTML is well formatted?

For your code, wouldn't it be better to use an "embedded view" to display your products? Like: You create a list view with the columns you want. Then, you insert it in an article and "boom voilà". That seems easier to do.

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Javascript error installing knowledge module
javascript error knowledge
Avatar
Avatar
Avatar
2
sept. 25
2115
Cannot import @website_sale/js/utils
javascript
Avatar
Avatar
2
nov. 25
566
Referenzen für Wissensdatenbank-Artikel?
knowledge
Avatar
Avatar
1
sept. 25
708
Cómo cerrar una transferencia interna al recibirla desde la vista de código de barras stock.picking
javascript
Avatar
0
juil. 25
1124
Why use the Lazy Translation function _lt()
javascript
Avatar
Avatar
1
juil. 25
6424
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now