Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
14450 มุมมอง

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

ผู้เขียน

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.

คำตอบที่ดีที่สุด

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.

คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

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 ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 21
4073
4
เม.ย. 16
12325
Product Template Columns sorting wrong แก้ไขแล้ว
1
พ.ค. 16
4447
1
ธ.ค. 24
4272
0
ก.ย. 23
2106