Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Reg - _inherits OpenERP

Subscribe

Get notified when there's activity on this post

This question has been flagged
_inherits
1 Reply
7822 Views
Avatar
omprakash

Hai Friends ,

  I am new for OpenERP , I have doubt regards _inherits delegation in OpnenERP .

Can anyone explain _inherits delegation with examples .

Thanks & Regards OMPRAKASH.A

2
Avatar
Discard
Avatar
klacus
Best Answer

Hi. The inherit methode has a lot of documentation around the net.: You can inherit: - xml for the views, and actions, wizzards, workflows - python codes for the deeper functionality, tables...etc

You can't inherit: - reports The first question is what do you want?

[Edited]

  1. Check the module what you want to inherit, thisi is you find out under addons dir.
  2. You must create a new module, according the followings:
    • create a folder same name what is your new module name.
    • put an __init__.py
    • put an __openerp__.py
    • put mymodule.py
    • put myview.xml inside the folder. All of that should be empty.

Put the following codes inside the __init__.py

import mymodule

this is a relation between the module and your main python code

Put the followings codes into the __openerp__.py

{
    "name" : "mymodule", # the name of the module
    "version" : "0.2", # the version of the module
    "author" : "your name", # your name :-)
    "website" : "", 
    "category" : "Generic Modules/Others", 
    "depends" : ["base","product"], #important points, as you see here must write the name of the inheritted modul name in our example product
    "description" : "your module description", 
    "init_xml" : ["myview.xml"], # important point your xml file what is definie the modified view points.
    "demo_xml" : [], 
    "update_xml" : [], #
    "active": False,
    "installable": True
}

put the following codes into the mymodule.py

class product_product(osv.osv):     
    _name = 'product.product'  # name of the inherited object, in sql you can find the table what name is product_product
    _inherit = 'product.product'
    _columns = { 
    'inheritted_recordname' : fields.char('shape',size=40, required = False, help='Some text what you want see...'),        # the inherited object column properties >> this meaning you create a new column in product_product table, what is char...and so on 
            }
product_product() # end of object def.

put the following code into the myview.xml

<record model="ir.ui.view" id="product_new_form_view_inherit"> 
    <field name="name">product.form.inherit</field>
    <field name="type">form</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view"/>
    <field name="arch" type="xml">
            <field name="name" position="after">                    
    <field name="inheritted_recordname"/>                    

    </field>
    </record>

about view inherit you can find out the docs at: http://doc.openerp.com/v6.0/developer/2_6_views_events/views/view_inheritence.html

  1. Save all.
  2. Refresh the module list
  3. Install your new module.

In this case, if everithing as well, you have a new record in product object. Please watching and understanding the code.

[EDITED 2]

class test(osv.osv): 
_name = "test" 
_inherits = {"notebook.notebook" : "notebook_id" , 
"bpc.bpc" : "bpc_id"} 
_table = "test" 
_description = "Simple bpc" 
_columns = { 
'test' : fields.text('test'), 
'notebook_id' : fields.test('notebook_id'),
'bpc_id' : fields.test('bpc_id'), }

test()

In this case is usable if you want to inherit the data table values. If just the structure, may be you have a clear situation, if you make it all, one by one... "This inheritance mechanism is usually called ” instance inheritance ” or ” value inheritance ”. A resource (instance) has the VALUES of its parents."

2
Avatar
Discard
omprakash
Author

Hi Klacus , Thanks for your reply . Actually i have question regards ( _inherits delegation ) OpenERP 1. It is possible for multiple inheritance in OpenERP , If it is possible can you please explain it with sample code . ? 2. Right now i building custom module and exploring the inheritance features in OpenERP (_inherit & _inherits delegation ) I have idea about _inherit but i have no idea about _inherits delegation . Can you please explain friend . And once again thank you klacus for your reply .

klacus

Hi. Ok. We are a bit closer. :-) Please post out your code, and we can see what we can do. You can write down what is your target, and may be I can explain to you how it's work. Please newer forget you need a lot of trial before your code will be good enough for the general use. I waiting for your codes. Regards.

omprakash
Author

Hi klacus , Thanks for your reply . I will just share with you what is my need & please clear my doubt . Basically i am java developer , For my client i need to move for python (OpenERP ) . I started learning OpenERP and i realized the excellent features . Actually my role will be for my client (To create a new custom module & customize the existing module ) . After i learn OpenERP technical document & i tried to implement . Klacus still i have no idea about _inherits delegation . http://doc.openerp.com/trunk/developers/server/03_module_dev_02/#inheritance-by-delegation-inherits

omprakash
Author

I used this link for my technical training . This is my sample code.... from osv import fields, osv import time

class test(osv.osv): _name = "test" _inherits = {"notebook.notebook" : "notebook_id" , "bpc.bpc" : "bpc_id"} _table = "test" _description = "Simple bpc" _columns = { 'test' : fields.text('test'), 'notebook_id' : fields.test('notebook_id'), 'bpc_id' : fields.test('bpc_id'), }

test()

klacus

Ok. I post you some basic features... :-)

omprakash
Author

klacus , whether the sample code for _inherits is correct or not .. please clarify my doubt . And once again thanks for your reply

klacus

If you have a problem/ question, just put here. If I can I will help you.

omprakash
Author

Hi Klacus , Thanks for your immediate reply . I can understand the point what you shared with me . Further i have doubt in Topics (Inheritance by Delegation - _inherits Syntax ::

class tiny_object(osv.osv) _name = 'tiny.object' _table = 'tiny_object' _inherits = { 'tiny.object_a': 'object_a_id', 'tiny.object_b': 'object_b_id', ... , 'tiny.object_n': 'object_n_id' } (...) Which was in the link http://doc.openerp.com/trunk/developers/server/03_module_dev_02/#inheritance-by-delegation-inherits

klacus

Yeah, the "delegation" key is a bit..... :-) So in the upside sample you can see all of the things what is there.: http://doc.openerp.com/trunk/developers/server/03_module_dev_02/#inheritance-by-delegation-inherits If you think, you question is answered please close the topic... Bye.

omprakash
Author

Hi klacus , thanks for reply . I will make use of it .

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
unable to add column in res.users table Solved
_inherits
Avatar
Avatar
Avatar
Avatar
Avatar
17
Dec 21
25778
how to change default digits of precision?
_inherits
Avatar
Avatar
1
Dec 18
20421
TypeError: The model "fleet.vehicle" specifies an unexisting parent class "fleet.vehicle"
_inherits
Avatar
Avatar
Avatar
2
Mar 15
9664
inherited view from base_calendar view
_inherits
Avatar
Avatar
2
Mar 15
11485
aading a new menuitem in fleet module
_inherits
Avatar
Avatar
2
Mar 15
6182
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now