Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5 Ответы
8999 Представления

How to add gender, birthdate and oder information to this page

BR

Ricardo Gross

Аватар
Отменить

if you want to add above fields in existing model than you need inheritance.

http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

Лучший ответ

Hi Recardo,

You can create custom field by Manually(From GUI) and Custom module(By the Python code).
GUI:

    Go under the Menu: (Settings > Technical > Database Structure > Models).

    Search res.partner model and add field which want you in res.partner form.

    After go under the menu (Settings > Technical > User Interface > Views).

    Search view_partner_form and then add those fields which you have have created manually after lang field.
    <field name="field_name1"/>

    <field name="field_name2"/>

    <field name="field_name3"/>

    After save the Form view and go under the Customer and refresh the page.

Custom Module(Technically):
    Create fields in python file (res_partner.py).

from odoo import api, fields, models, _

class Partner(models.Model):
_inherit = "res.partner"

birth_date = fields.Date('Birth Date')
    gender = fields.Selection([('male', 'Male'),('female', 'Female')], string='Gender')

    Create View File (res_partner_view.xml)

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Inherit partner form view -->
<record id="view_partner_form_inherit" model="ir.ui.view">
<field name="name">res.partner.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="lang" position="after">
<field name="birth_date"/>
                    <field name="gender"/>
</field>
</field>
</record>

 Hope this will help you.

Thanks.

Аватар
Отменить
Автор Лучший ответ

Perfect, thank you very much for your answers !! :-)

BR

Ricardo

Аватар
Отменить
Лучший ответ

you can achieve this using inheritance:

model.py

class groups(models.Model):
 _inherit = 'res.groups'
 # we inherited res.groups model which is Odoo/OpenERP built in model and created two fields in that model.
 field_1 = fields.Char(required=True,string="Field One")
 field_2 = fields.Boolean(default=False,string="Field Two")  

xml

<openerp>
    <data>
        <record model="ir.ui.view" id="res_group_form_view_inherited">
            <field name="name">res.group.form.view.inherited</field>
            <field name="model">res.groups</field>
            <field name="inherit_id" ref="base.view_groups_form" />
            <!-- <field name="groups_id" eval="[(6, 0, [ref('obe_core.obe_coordinator')])]"/> -->
            <field name="priority" eval="15"/>
            <field name="arch" type="xml">

                <xpath expr="//field[@name='name']" position="after">
                    <field  name="field_1"/>
                </xpath>                
                
                <xpath expr="//field[@name='user_name']" position="after">
                    <field  name="field_2"/>
                </xpath>        

            </field>                               
        </record>
    </data>
</openerp> 


Аватар
Отменить
Лучший ответ

Hi Ricardo Gross,
Actually, I did not get your requirement correctly,
If you want to add extra information in contacts (res.partner) you just do one thing,
Just inherits the form [ base.view_partner_form]

add the new field that you need in res.partner. and don't forget to add the fields in python files too.
Thank you.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
окт. 25
2164
2
июл. 25
1390
1
сент. 24
1831
2
апр. 22
3656
2
мар. 15
8149