Skip to Content
Menu
This question has been flagged
3 Replies
12745 Views

Hello,

Is it possible to add a new column in the table "Contact" or "User". I want to add the first name of the user.

Thank you for your help.

Avatar
Discard

You may want to read the following document before adding a firstname column. The first/last name denomination is very Europe-centric. https://www.w3.org/International/questions/qa-personal-names

Author

Thank you Martin your document made me think about it. But knowing the name and the first name is also usefull when we want to find some duplicates.

Best Answer

Hello Lince,


You can add new column in the any tables using inherit.

For Ex :-

In py

class Users(models.Model):

     _inherit = 'res.users'

     first_name = fields.Char('First Name')


In Xml

<record id="res_users_form_view_inherit" model="ir.ui.view">

    <field name="name">res.users.form.view.inherit</field>

    <field name="model">res.users</field>

    <field name="inherit_id" ref="base.view_users_form"/>

    <field name="arch" type="xml">

        <xpath expr="/form/sheet/div[@class='oe_title']/group/field[@name='partner_id']" position="after">

            <field name="first_name"/>

        </xpath>

    </field>

</record>


Now First name is display after Related Partner in Users form view.

For Contact, You will inherit res.partner model.

Hope it will works for you.

Thanks,

Avatar
Discard
Author

Thank you Jignesh Mehta. I'll see it as soon as I find the .py file corresponding.

Best Answer

There is already a module available in the App store for this purpose: https://www.odoo.com/apps/modules/9.0/partner_firstname/     

You should be careful to not break a lot of things if you do not ensure that the regular field "name" still has the proper value.

Avatar
Discard
Best Answer

Note: i am assuming that you are not a developer.

For Adding a new field in any  model follow these steps:

  1. Go to setting-> technical->Database Structure ->Fields 

  2. Click on Create

  3. Put the Field Name(x_first_name),Model(Users) ,Label/String[First Name] , Type[Text] etc.

  4. Save it.

Now open the corresponding  view in edit mode ,put your field like  <field name = "x_first_name"/> and save.


 


 
Avatar
Discard

Hello Sharma. Your method is for adding field is wrong. If you create new database then you want to add again this fields. But If you code for this, it is available in any database with installed custom modules.

Hi @Jignesh Mehta , yes i am agree with these words"If you create new database then you want to add again this fields.", but i have ready mention that it's for non developer only bcz they don't want to mess-up with the codes . "Note: i am assuming that you are not a developer."

Related Posts Replies Views Activity
2
Apr 21
2797
4
Apr 16
10914
1
May 16
3731
0
Sep 23
498
0
Sep 23
451