Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
javascriptknowledge
1 Odpoveď
1779 Zobrazenia
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
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Javascript error installing knowledge module
javascript error knowledge
Avatar
Avatar
Avatar
2
sep 25
2115
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
júl 25
1124
Why use the Lazy Translation function _lt()
javascript
Avatar
Avatar
1
júl 25
6424
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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