Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
javascriptknowledge
1 Răspunde
1786 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Julien Banken (jbn)
Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Javascript error installing knowledge module
javascript error knowledge
Imagine profil
Imagine profil
Imagine profil
2
sept. 25
2122
Cannot import @website_sale/js/utils
javascript
Imagine profil
Imagine profil
2
nov. 25
576
Referenzen für Wissensdatenbank-Artikel?
knowledge
Imagine profil
Imagine profil
1
sept. 25
713
Cómo cerrar una transferencia interna al recibirla desde la vista de código de barras stock.picking
javascript
Imagine profil
0
iul. 25
1126
Why use the Lazy Translation function _lt()
javascript
Imagine profil
Imagine profil
1
iul. 25
6428
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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