Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
javascriptknowledge
1 Odgovori
1780 Prikazi
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
Opusti
Avatar
Julien Banken (jbn)
Best Answer

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Javascript error installing knowledge module
javascript error knowledge
Avatar
Avatar
Avatar
2
sep. 25
2116
Cannot import @website_sale/js/utils
javascript
Avatar
Avatar
2
nov. 25
567
Referenzen für Wissensdatenbank-Artikel?
knowledge
Avatar
Avatar
1
sep. 25
708
Cómo cerrar una transferencia interna al recibirla desde la vista de código de barras stock.picking
javascript
Avatar
0
jul. 25
1124
Why use the Lazy Translation function _lt()
javascript
Avatar
Avatar
1
jul. 25
6424
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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