Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
3 Besvarelser
14462 Visninger

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
Kassér

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

Forfatter

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.

Bedste svar

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
Kassér
Forfatter

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

Bedste svar

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
Kassér
Bedste svar

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
Kassér

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 Besvarelser Visninger Aktivitet
2
apr. 21
4078
4
apr. 16
12331
1
maj 16
4449
1
dec. 24
4273
0
sep. 23
2109