Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Multiple inheritence in single .py file

By
umer farooq
on 1/21/14, 9:42 AM 954 views

Hello I am able to bring two custom fields in project.project model. this is my custom_module.py code: #################################custom_module.py####################### from openerp.osv import fields, osv

class legacy_projects(osv.osv):

_inherit = "project.project"

_columns = {

'test': fields.integer('Test', size=11),
'test1':fields.char('umer', size=64)

}

_defaults ={ 'test': 0 }

legacy_projects(); ############################XML########################################### <openerp> <data> <record model="ir.ui.view" id="legacy_projects_project"> <field name="name">project.project.form</field> <field name="model">project.project</field> <field name="inherit_id" ref="project.edit_project"/> <field name="arch" type="xml"> <xpath expr="/form/sheet/group/group[2]/field[@name='partner_id']" position="after">

            <field name="test" />
            <field name="test1" />
        </xpath>
    </field>
</record>

</data> </openerp>

It works fyn and bringing two new fields in Project module. now in my custom_module.py file i want this file to be inherrited in other modules as well how can I do multiple inherritence in once .py file like After Default defintion should i start _inherit= "account.invoice" if yes then how to define it's Xml in the above given code kindly help me in it.. Thanks in Advance

I have tried this : .py file..........................from openerp.osv import fields, osv

class legacy_projects(osv.osv):

_inherit = "project.project"

_columns = {

'test': fields.integer('Test', size=11),
'test1':fields.char('umer', size=64),
'legacy_projects_id': fields.integer('Legacy project ID', size=11),

}

_defaults ={ 'test': 0 'legacy_projects_id': 0, } _inherit = "account.invoice"

_columns = { 'test2' : fields.char('TESTING FIELD' , size=64),

legacy_projects();

umer farooq
on 1/21/14, 10:45 AM

and in xml created a new record in the same above xml file. <record model="ir.ui.view" id="account_invoice_view"> <field name="name">account.invoice.form</field> <field name="model">account.invoice</field> <field name="inherit_id" ref="account.invoice_form" /> <field name="arch" type="xml"> <xpath expr="/form/sheet/group/group[2]/field[@name='fiscal_position']" position="after">

            &lt;field name="test2"/&gt;

        &lt;/xpath&gt;      
&lt;/
umer farooq
on 1/21/14, 10:50 AM

then updated my module list then install Cutom_module:in project.project test and test1 fields appear but not in account.invoice nothing happens :S i dont know i think i 've messed it up.please help me in it.

umer farooq
on 1/21/14, 10:53 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 1/21/14, 9:42 AM
Seen: 954 times
Last updated: 3/16/15, 8:10 AM