Odoo Help

Welcome!

This community 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.

0

Add new column in the Contact/User tables, to add a column with the "First name" - Odoo9

By
Lince
on 4/25/16, 5:52 PM 278 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.

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

Martin Trigaux (mat)
on 4/26/16, 3:04 AM

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.

Lince
on 5/10/16, 2:16 PM
0

Jignesh Mehta

--Jignesh Mehta--
2081
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 4/26/16, 2:04 AM

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,

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

Lince
on 5/10/16, 2:18 PM
0

Ermin Trevisan

--Ermin Trevisan--
3524
| 6 3 7
Walchwil, Switzerland
--Ermin Trevisan--


Ermin Trevisan
On 4/26/16, 2:39 AM

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.

-1

Prakash Sharma

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 4/26/16, 2:20 AM

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.


 


 

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.

Jignesh Mehta
on 4/26/16, 8:23 AM

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

Prakash Sharma
on 4/26/16, 8:39 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/25/16, 5:52 PM
Seen: 278 times
Last updated: 4/26/16, 2:39 AM