Skip to Content
मेन्यू
This question has been flagged
3 Replies
16771 Views

I'm new to OpenErp. I want to Add a new field "mother_name" in res.partner.So i have added the following code to res.partner.py In column's i have add like this

_columns = {
    'name': fields.char('Name', size=128, required=True, select=True),
    'date': fields.date('Date', select=1),
    'title': fields.many2one('res.partner.title', 'Title'),
    'parent_id': fields.many2one('res.partner', 'Related Company'),
    'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts', domain=[('active','=',True)]), # force "active_test" domain to bypass _search() override    
    'ref': fields.char('Reference', size=64, select=1),
    'date_delivery': fields.date('Expected Delivery Date'),
    'mother_ln': fields.char('Mother', size=64),
     .
     .
     .
     }

Now in res_partner_view.xml . I'm using the following code

    <record id="view_partner_tree" model="ir.ui.view">
        <field name="name">res.partner.tree</field>
        <field name="model">res.partner</field>
        <field eval="8" name="priority"/>
        <field name="arch" type="xml">
            <tree string="Contacts">
                <field name="name"/>
                <field name="function" invisible="1"/>
                <field name="phone"/>
                <field name="email"/>
                <field name="user_id" invisible="1"/>
                <field name="is_company" invisible="1"/>
                <field name="country" invisible="1"/>
                <field name="country_id" invisible="1"/>
                <field name="date_delivery"/>
                <field name="mother_ln"/>
                <field name="parent_id" invisible="1"/>
            </tree>
        </field>
    </record>

<record id="view_partner_form" model="ir.ui.view"> <field name="name">res.partner.form</field> <field name="model">res.partner</field> <field eval="1" name="priority"/> <field name="arch" type="xml"> <form string="Partners" version="7.0"> <sheet> <field name="image" widget="image" class="oe_left oe_avatar" options="{"preview_image": "image_medium", "size": [90, 90]}"/>

<label for="name"/> ( <field name="is_company" on_change="onchange_type(is_company)" class="oe_inline"/> <label for="is_company" string="Is a Company?"/>)

<field name="name" default_focus="1" placeholder="Name"/>

<field name="parent_id" placeholder="Company" domain="[('is_company', '=', True)]" context="{'default_is_company': True, 'default_supplier': supplier}" attrs="{'invisible': [('is_company','=', True),('parent_id', '=', False)]}" on_change="onchange_address(use_parent_address, parent_id)"/>

                <group>
                    <group>
                        <label for="type" attrs="{'invisible': [('parent_id','=', False)]}"/>
                        <div attrs="{'invisible': [('parent_id','=', False)]}" name="div_type">
                            <field class="oe_inline"
                                name="type"/>
                        </div>

                        <label for="street" string="Address"/>
                        <div>
                            <field name="use_parent_address" class="oe_edit_only oe_inline"
                                   on_change="onchange_address(use_parent_address, parent_id)"
                                   attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
                            <label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
                            <button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"
                                    attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>
                            <field name="street" placeholder="Street..."  attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            <field name="street2"  attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            <div class="address_format">
                                <field name="city" placeholder="City" style="width: 40%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                <field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                <field name="zip" placeholder="ZIP" style="width: 20%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            </div>
                            <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                        </div>

                    </group>
                    <group>
                      <!-- We Don't require Job Position for Customer -->
                      <!--   <field name="function" placeholder="e.g. Sales Director"
                            attrs="{'invisible': [('is_company','=', True)]}"/> -->
                        <field name="phone" placeholder="e.g. +32.81.81.37.00"/>
                        <field name="mobile"/>
                        <field name="fax"/>
                        <field name="email" widget="email"/>
                        <!-- <field name="title" domain="[('domain', '=', 'contact')]"
                            options='{"no_open": True}' attrs="{'invisible': [('is_company','=', True)]}" /> -->
                    </group>
                    <field name="date_delivery"/>
                    <field name="mother_ln"/>
                    </group>
                    .
                    .
                    .
             </record>
Avatar
Discard
Best Answer

Hello

Add new field in py file

columns={

mother_name': fields.char('Mother Name', size=64),

}

Xml file <tree> <field name="mother_name"/> </tree>

<form> <field name="mother_name"/> </form>
Avatar
Discard
Author

i've give the same dude.But i'm getting the following error "ProgrammingError: column res_partner.mother_name does not exist"

Author

i'm getting the following error
OpenERP Server Error

Client Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 867, in authenticate req.session.authenticate(db, login, password, env) File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", ProgrammingError: column res_partner.mother_name does not exist LINE 1: ...,res_partne

Have u updated the database by running -u all -d ur_db_name?

Best Answer

Hello Nitesh,

try this code may be help full

in .py file

from openerp.osv import osv, fields

class res_partner(osv.Model):
    _inherit = 'res.partner'
    _columns = {
        'mother_name': fields.char('Mother Name', size=64)
    }

in .xml file

<openerp>
    <data>
        <record model="ir.ui.view" id="view_partner_form_inherited">
            <field name="name">view.partner.form.inherited</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='website']" position="after">
                    <field name="mother_name"/>
                </xpath>
            </field>
        </record>
    </data>
</openerp>

if you find this answer helpful, please give me a thumbs up vote    

Thanks & Regards,

Ankit H Gandhi

Avatar
Discard
Best Answer

Hello,

I have not tried python yet but I can tell you you can add a field using Odoo's technical interface.

Go to the database and add the field (Is it the error "the column does not exist" ???)

Then go to the views res.partner.tree and res.partner.form and add the field so it appears on the screen.

Best regards,

José

Avatar
Discard
Related Posts Replies Views Activity
2
अक्तू॰ 23
5676
3
सित॰ 23
2518
0
मई 23
2564
1
मई 23
2022
1
अप्रैल 23
1797