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
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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

How to target templates, with an ID of template.

S'inscrire

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

Cette question a été signalée
templatesxpathodoo16features
4 Réponses
5527 Vues
Avatar
Ross

Hi,

I want to add the default code to the website search bar dropdown, but i'm unsure how to target this particular template. 

The template is found here: addons/website/static/src/snippets/s_searchbar/000.xml

id="template"

t-tname="website.s_searchbar.autocomplete"

Any advice would be appreciated.


Thanks,

Ross.

0
Avatar
Ignorer
Avatar
Shepai Ellyn
Meilleure réponse

You can try below. I think it is what you are looking for.

1
Avatar
Ignorer
Shepai Ellyn

Add this code to your view...
<template id="assets_frontend" inherit_id="website_sale.assets_frontend">
<xpath expr="link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/module_name/static/src/scss/style.scss"/>
</xpath>
</template>
For reports...
<template id="report_assets_common" inherit_id="web.report_assets_common">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/module_name/static/src/scss/style.scss"/>
</xpath>
</template>
@https://helixjumponline.com

Avatar
Support GeminateCS
Meilleure réponse

Hii Ross,
If you want to target and add particular fields of your model , you can achieve this by adding this in xml,
id='your_custom_template'  inherit_id='Module_name.Template_ID'
//your functionality of code

and if you want to replace the whole template 
id='Module_name.Template_ID'  name='Name of Template'
//your functionality of code

I Hope this information will helpful for you.
Feel free for further Assistance on contact@geminatecs.com
Thank You,
Geminate Consultancy Services
w : www.geminatecs.com

1
Avatar
Ignorer
Avatar
shubham shiroya
Meilleure réponse

you can create a custom module and inherit the existing template to make the necessary modifications. Here's a step-by-step guide:

  1. Create a new custom module (e.g., custom_website) with the necessary module structure.

  2. Inside your custom module, create a new XML file (e.g., custom_searchbar_templates.xml) and define your modifications. The file should be placed in the static/src/snippets/ directory of your custom module.

  3. In the XML file, inherit the existing template (website.s_searchbar.autocomplete) using the template tag with the inherit_id attribute. Set the inherit_id value to the original template's id attribute.

  4. Within the inherited template, add your default code or modifications.

Here's an example of how your custom_searchbar_templates.xml file might look:

templates id="template" xml:space="preserve">
t t-extend="website.s_searchbar.autocomplete">
#!-- Inherit the existing template 
t t-inherit="website.s_searchbar.autocomplete">
#Add your modifications or default code 
            # For example, adding a default search suggestion 
t t-set="search_suggestion" t-value="'Your default search suggestion'"/>
/t>
/t>
/templates>


in your custom module's manifest file (__manifest__.py), make sure to include the XML file by adding it to the data section:

1
Avatar
Ignorer
Avatar
Ross
Auteur Meilleure réponse

Hi shubham shiroya,

I get the following error:

AssertionError: Element odoo has extra content: templates, line 3
XML:

xml version="1.0" encoding="utf-8"?>

odoo>

​templates id="template" xml:space="preserve">

​​t t-extend="website.s_searchbar.autocomplete">

​ ​​t t-inherit="website.s_searchbar.autocomplete">

​​​ ​t t-set="search_suggestion"t-value="'Your default search suggestion'"/>

​ ​​/t>

​ ​/t>

​/templates>

/odoo>

0
Avatar
Ignorer
shubham shiroya

try this code:
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-extend="website.s_searchbar.autocomplete">
<!-- Add your modifications to the template here -->
<!-- For example, add a default code -->
<t t-jquery=".dropdown-item" t-operation="append">
<li class="dropdown-item" role="option" data-autocomplete-code="your_default_code">Your Default Code</li>
</t>
</t>
</templates>

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é
v16 web.TranslationDialogWidget Extension not working
templates odoo16features
Avatar
0
mars 23
2246
Where is the docs variable used in the template defined?
templates reporting odoo16features
Avatar
Avatar
1
mars 24
2347
odoo16: how to reference <t element in xpath expr
template xpath odoo16features
Avatar
Avatar
Avatar
2
mars 24
3911
Project Templates
templates projects odoo16features
Avatar
Avatar
2
juil. 23
10003
report odoo16 Résolu
templates report odoo16features
Avatar
Avatar
1
févr. 23
9665
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