Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
14467 Vistas

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
Descartar

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

Autor

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.

Mejor respuesta

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
Descartar
Autor

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

Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar

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

Publicaciones relacionadas Respuestas Vistas Actividad
2
abr 21
4078
4
abr 16
12333
1
may 16
4461
1
dic 24
4273
0
sept 23
2112