Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How add new filed to res.partner ?

Subscribe

Get notified when there's activity on this post

This question has been flagged
res.partner
3 Replies
17746 Views
Avatar
NiteshMVP

I'm new to OpenErp. I want to Add a new field "mother_name" in res.partner.So i have added the following code to res.partner.py In column's i have add like this

_columns = {
    'name': fields.char('Name', size=128, required=True, select=True),
    'date': fields.date('Date', select=1),
    'title': fields.many2one('res.partner.title', 'Title'),
    'parent_id': fields.many2one('res.partner', 'Related Company'),
    'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts', domain=[('active','=',True)]), # force "active_test" domain to bypass _search() override    
    'ref': fields.char('Reference', size=64, select=1),
    'date_delivery': fields.date('Expected Delivery Date'),
    'mother_ln': fields.char('Mother', size=64),
     .
     .
     .
     }

Now in res_partner_view.xml . I'm using the following code

    <record id="view_partner_tree" model="ir.ui.view">
        <field name="name">res.partner.tree</field>
        <field name="model">res.partner</field>
        <field eval="8" name="priority"/>
        <field name="arch" type="xml">
            <tree string="Contacts">
                <field name="name"/>
                <field name="function" invisible="1"/>
                <field name="phone"/>
                <field name="email"/>
                <field name="user_id" invisible="1"/>
                <field name="is_company" invisible="1"/>
                <field name="country" invisible="1"/>
                <field name="country_id" invisible="1"/>
                <field name="date_delivery"/>
                <field name="mother_ln"/>
                <field name="parent_id" invisible="1"/>
            </tree>
        </field>
    </record>

<record id="view_partner_form" model="ir.ui.view"> <field name="name">res.partner.form</field> <field name="model">res.partner</field> <field eval="1" name="priority"/> <field name="arch" type="xml"> <form string="Partners" version="7.0"> <sheet> <field name="image" widget="image" class="oe_left oe_avatar" options="{"preview_image": "image_medium", "size": [90, 90]}"/>

<label for="name"/> ( <field name="is_company" on_change="onchange_type(is_company)" class="oe_inline"/> <label for="is_company" string="Is a Company?"/>)

<field name="name" default_focus="1" placeholder="Name"/>

<field name="parent_id" placeholder="Company" domain="[('is_company', '=', True)]" context="{'default_is_company': True, 'default_supplier': supplier}" attrs="{'invisible': [('is_company','=', True),('parent_id', '=', False)]}" on_change="onchange_address(use_parent_address, parent_id)"/>

                <group>
                    <group>
                        <label for="type" attrs="{'invisible': [('parent_id','=', False)]}"/>
                        <div attrs="{'invisible': [('parent_id','=', False)]}" name="div_type">
                            <field class="oe_inline"
                                name="type"/>
                        </div>

                        <label for="street" string="Address"/>
                        <div>
                            <field name="use_parent_address" class="oe_edit_only oe_inline"
                                   on_change="onchange_address(use_parent_address, parent_id)"
                                   attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
                            <label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
                            <button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"
                                    attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>
                            <field name="street" placeholder="Street..."  attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            <field name="street2"  attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            <div class="address_format">
                                <field name="city" placeholder="City" style="width: 40%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                <field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                <field name="zip" placeholder="ZIP" style="width: 20%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            </div>
                            <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                        </div>

                    </group>
                    <group>
                      <!-- We Don't require Job Position for Customer -->
                      <!--   <field name="function" placeholder="e.g. Sales Director"
                            attrs="{'invisible': [('is_company','=', True)]}"/> -->
                        <field name="phone" placeholder="e.g. +32.81.81.37.00"/>
                        <field name="mobile"/>
                        <field name="fax"/>
                        <field name="email" widget="email"/>
                        <!-- <field name="title" domain="[('domain', '=', 'contact')]"
                            options='{"no_open": True}' attrs="{'invisible': [('is_company','=', True)]}" /> -->
                    </group>
                    <field name="date_delivery"/>
                    <field name="mother_ln"/>
                    </group>
                    .
                    .
                    .
             </record>
0
Avatar
Discard
Avatar
Shashank Verma
Best Answer

Hello

Add new field in py file

columns={

mother_name': fields.char('Mother Name', size=64),

}

Xml file <tree> <field name="mother_name"/> </tree>

<form> <field name="mother_name"/> </form>
0
Avatar
Discard
NiteshMVP
Author

i've give the same dude.But i'm getting the following error "ProgrammingError: column res_partner.mother_name does not exist"

NiteshMVP
Author

i'm getting the following error
OpenERP Server Error

Client Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 867, in authenticate req.session.authenticate(db, login, password, env) File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", ProgrammingError: column res_partner.mother_name does not exist LINE 1: ...,res_partne

Shashank Verma

Have u updated the database by running -u all -d ur_db_name?

Avatar
Ankit H Gandhi(AHG)
Best Answer

Hello Nitesh,

try this code may be help full

in .py file

from openerp.osv import osv, fields

class res_partner(osv.Model):
    _inherit = 'res.partner'
    _columns = {
        'mother_name': fields.char('Mother Name', size=64)
    }

in .xml file

<openerp>
    <data>
        <record model="ir.ui.view" id="view_partner_form_inherited">
            <field name="name">view.partner.form.inherited</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='website']" position="after">
                    <field name="mother_name"/>
                </xpath>
            </field>
        </record>
    </data>
</openerp>

if you find this answer helpful, please give me a thumbs up vote    

Thanks & Regards,

Ankit H Gandhi

0
Avatar
Discard
Avatar
José DESGRIS
Best Answer

Hello,

I have not tried python yet but I can tell you you can add a field using Odoo's technical interface.

Go to the database and add the field (Is it the error "the column does not exist" ???)

Then go to the views res.partner.tree and res.partner.form and add the field so it appears on the screen.

Best regards,

José

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Domain for res.partner having which are tagged with users ? Solved
res.partner
Avatar
Avatar
2
Oct 23
6616
Restrict duplicate phone number creation in res_partner odoo 16
res.partner
Avatar
Avatar
Avatar
Avatar
3
Sep 23
3424
Insert/update via API trying to create contact with contact image included, not inserting or updating field image_1920 on res.partner
res.partner
Avatar
0
May 23
3393
Bonjour à tous comment faire de telle sort qu'un utilisateur ne voit que ses propres "contact" créé.
res.partner
Avatar
Avatar
1
May 23
2603
Hello everyone how to make such a fate that a user sees only his own "contact" created Solved
res.partner
Avatar
Avatar
1
Apr 23
2382
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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