Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Add new custom fields to the odoo contacts module

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
2 Răspunsuri
4988 Vizualizări
Imagine profil
Salmi Sifeddine

so i'm trying to add new fields to show up when you create a new contact, with the name, adress, tax ID ...

so i created a custom module called custom_contact this is my models/contacto.py
 and i changed the contacts_view.xml in the odoo contacts module to use my custom module 


   

        Contacts

        ir.actions.act_window

        custom_contact.contacto

        kanban,tree,form,activity

       

        {'default_is_company': True}

       

         

            Create a Contact in your address book

         

            Odoo helps you track all activities related to your contacts.

         

       

   



when i go to create a new contact and i hover on one of the fields i see that Model is : custom_contact.contacto

now how i can add those fields and make them visible

	​
from odoo import models, fields

class Contacto(models.Model):   
_name = 'custom_contact.contacto'   
_inherits = {'res.partner': 'partner_id'}   
_description = 'Contacto'   
   
# Custom fields   
nis = fields.Char(string='NIS')   
nif = fields.Char(string='NIF')   
ai = fields.Char(string='AI')   
rc = fields.Char(string='RC')
partner_id = fields.Many2one('res.partner', required=True, ondelete='restrict', auto_join=True, index=True,        string='Related Partner', help='Partner-related data of the user')

# Inherit existing Many2many fields   
channel_ids = fields.Many2many(comodel_name='res.partner',        relation='res_partner_channel_rel',column1='partner_id', column2='channel_id',        string='Channels')
meeting_ids = fields.Many2many(comodel_name='res.partner',        relation='res_partner_meeting_rel', column1='partner_id', column2='meeting_id',        string='Meetings')

0
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

Hi,

If you need to add new fields in the contacts module , you need to inherit the model "res.partner" model instead of "res.users"

example:

class ResPartner(model.Models):

    _inherit ="res.partner"


nis = fields.Char(string='NIS')

    nif = fields.Char(string='NIF')  

    ai = fields.Char(string='AI')  

    rc = fields.Char(string='RC')


And inherit the form of the "res.partner" to add the fields in the form view


<record id="view_partner_form" model="ir.ui.view">
        <field name="name">
view.partner.form.inherit.res.partner
        </field>
<field name="model">helpdesk.ticket</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <field name="name" position="after">
                <field name="nis" i" />
                <field name="nif" "/>

                 <field name="ai" "/>

                <field name="rc" "/>
            </field>
        </field>
    </record>

Hope it helps

1
Imagine profil
Abandonează
Imagine profil
Dương Nguyễn
Cel mai bun răspuns

I have so advice on your code like this:

1. If you only need to add field and display in for a partner, you should use _inherit instead of _inherits.

2. To add your new fields in the formview of contact, you just need to do exactly like this https://github.com/odoo/odoo/blob/128475bf2ac966f98f488833e5ff781312055b76/addons/base_address_extended/views/base_address_extended.xml#L61

Then remember to load in manifest sir and to make it invisible, add this invisible="1" for the fields you want it to be invisible.

Hope this help sir.

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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