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

How to add a field to a form that appears on button click?

S'inscrire

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

Cette question a été signalée
formfieldxpath
1 Répondre
8720 Vues
Avatar
Art

I'm trying to add a field "street3" to the form that appears after you click "create" button in "contacts & addresses" tab of the vendor form (res.partner model). I can add a field to this tab after the button, but I can't add it to the form this button generates.

Here is my code:

class add_vendor1099(models.Model):
    _inherit = 'res.partner'
    street3 = fields.Char()
<odoo>	<data>	
<record id="add_vendor1099_view_inherit" model="ir.ui.view">
<field name="name">res.partner.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
  <xpath expr="//form/sheet/notebook/page/field[@name='child_ids']/form/sheet/group/field[@name='street2']" position='after'>
      <field name="street3" placeholder="Street 3..."/>
  </xpath>
</field>
</record>
</data></odoo>
ValueError: Can't validate view:
Element '<xpath expr="//form/sheet/notebook/page/field[@name='child_ids']/form/sheet/group/field[@name='street2']">' cannot be located in parent view 

I tried all kinds of paths to that place where I need to add my field, but it's not working. What is the correct xpath? 

0
Avatar
Ignorer
Avatar
Art
Auteur Meilleure réponse

So I kinda solved my issue, but not on 100%. Here is a piece of code of "base.view_partner_form" that you can get by clicking on "Edit FormView" in the developer mode:

<form string="Contact / Address">                                    
    <sheet>
        <field name="type" required="1" widget="radio" options="{'horizontal': true}"/><hr/>
        <group>
            <group attrs="{'invisible': [('type','=', 'contact')]}">
                <label for="street" string="Address"/>
                    <div>
                        <div class="o_address_format" name="div_address">
                            <field name="street" placeholder="Street..." class="o_address_street"/>
                            <field name="street2" placeholder="Street 2..." class="o_address_street"/>
                            <field name="city" placeholder="City" class="o_address_city"/>
                            <field name="state_id" class="o_address_state" placeholder="State" options="{&quot;no_open&quot;: True}" context="{'country_id': country_id, 'zip': zip}"/>
                            <field name="zip" placeholder="ZIP" class="o_address_zip"/>
                            <field name="country_id" placeholder="Country" class="o_address_country" options="{&quot;no_open&quot;: True, &quot;no_create&quot;: True}"/>
                        </div>
                    </div>
            </group>

and here is what i did to add my custom field "street3" after "street2":

<xpath expr="//div[@name='div_address']/field[@name='street2']" position="after">             		
    <field name="street3" placeholder="Street 3..."/>
</xpath>

But here is what I noticed. If you add "street3" field to the main form and the same field to the form that appears after you click the button in "Contacts" tab then you'll see that they're not linked. What i mean is if you type in "street" and "street2" fields in the main form then you'll see the same input in the same fields on the appeared form after you click a button, but it's not like that when you add your own custom fields.

I think the same field needs to be added somewhere else to make it happen. 


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é
Can't use xpath while inheriting crm.lead form view
form view field inherit xpath
Avatar
Avatar
1
mars 15
6797
[v14] Is it possible to see the xml code with the changes made by an Xpath? Résolu
field xpath result
Avatar
Avatar
2
mai 21
3700
How to make field required depending on the create_date timestamp? Résolu
form field odoo10
Avatar
Avatar
1
nov. 19
5847
edit the label name of "Internal Reference" Product
form field label
Avatar
Avatar
Avatar
2
nov. 18
5876
How to Remove Zip Code Field from Checkout Form (without Controller Access)
form field zipcode chekcout
Avatar
Avatar
Avatar
2
oct. 24
2678
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