Odoo Help


How add new filed to res.partner ?

on 1/24/14, 1:55 AM 6,192 views

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"/>

<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)"/>

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

                        <label for="street" string="Address"/>
                            <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)]}"/>
                            <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' attrs="{'readonly': [('use_parent_address','=',True)]}"/>

                      <!-- 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. +"/>
                        <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)]}" /> -->
                    <field name="date_delivery"/>
                    <field name="mother_ln"/>
On 2/9/15, 7:15 AM


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,


shashank verma
On 1/24/14, 2:04 AM


Add new field in py file


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


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

<form> <field name="mother_name"/> </form>

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

on 1/24/14, 2:12 AM

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

on 1/24/14, 2:22 AM

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

shashank verma
on 1/24/14, 3:57 AM

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 2/9/15, 6:55 AM

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

        <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"/>

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

Thanks & Regards,

Ankit H Gandhi

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 1/24/14, 1:55 AM
Seen: 6192 times
Last updated: 3/16/15, 8:10 AM