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č

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
formfieldxpath
1 Odgovori
8706 Prikazi
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
Opusti
Avatar
Art
Avtor Best Answer

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