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

[Solved] Inherit fields to existing tables

Subscribe

Get notified when there's activity on this post

This question has been flagged
pythonpython2.7odooodoo10
4 Replies
10431 Views
Avatar
Fazryan Fareka Riznendi

Hiiii,
How to inherit field to existing tables?

I've tried various things, but it's hard to understand,

i want to inherit my field(on my addons) to model asset.

this my code ;

class Aset(models.Model): #addons field
    _inherit='asset.asset' 
    
    asset_number = fields.Char('Item Code/Reg', size=64)
    no_pol=fields.Char('Police Number')
    many_units=fields.Char('Number Of Units', default='1')
    item_type_id=fields.Many2one('item_type', string='Item Type')
    colour=fields.Char('Colour')
    machine_number=fields.Char('Number Machine')
    chassiss=fields.Char('Chassis Number')
    fill_in_the_slider=fields.Char('Slider')
    bpkb_no=fields.Char('BPKB No')
    year=fields.Char('Year')

xml ;

<record model="ir.ui.view" id="asset_asset_form_view">
    <field name="name">asset_asset_form</field>
    <field name="model">asset.asset</field>
    <field name="inherit_id" ref="asset.assets_form_view" />
    <field name="arch" type="xml">
        <page position='inside'>
            <group position="inside">
                <field name='serial'>
            <group>
                <field name='color'/>
            </group>
                </field>
       </group>
</page>

Thanks before...

0
Avatar
Discard
Avatar
La Jayuhni Yarsyah
Best Answer

Based on your code  on <page position='inside'> that  means "Put new tags Inside Element <Page> on referenced view (asset.assets_form_view)"

So the result as attached images. because odoo will render xml structure like this
<page string="Info">
    <group>
        <group>
            ******original fields on group top left
        </group>
    </group>
    <group string="Warranty">
        <group>
            *** Original fields on group bottom left
        </group>
        <group>
            *** Original fields on group bottom right
        </group>
    </group>


    <!-- THE APPENDED TAGS by <page position="inside">**TAGS**</page> -->
    <group>
        <field name='serial'>
    </group>
    <group>
        <field name='color'/>
    </group>
    <!-- END -->
</page>


So for you expected result like image that you attached, maybe you can try like this

<xpath expr="//form/sheet/notebook/page/group[1]" position="inside">
    **Appended tags
</xpath>
** Using group[1] or group (depends on referenced structure)

or

<xpath expr="//form/sheet/notebook/page/group[1]/group" position="after">
    **Appended tags
</xpath>

Note:
The expression depends by referenced views,,so you must modify it base on referenced xml view structure (asset.assets_form_view)

You can see the video that referenced by @Cybrosys before
And please learn about \XPATH\ expression\\ \/\ i\nheriting  View ON Odoo.

Regards

1
Avatar
Discard
Fazryan Fareka Riznendi
Author

Thanks for response.

I do both examples,

still not as I expected sir.

the example above makes the field in an existing group, it is almost exactly what I want, but rather want to create a new group and be next to the existing group (as in the picture)

La Jayuhni Yarsyah

So for more please post the original view to inherit (asset.assets_form_view)

And your full xml view code , so me or anyone can help more detail,,

Regards..

Fazryan Fareka Riznendi
Author

can it be like this? and which object should I edit?

https://drive.google.com/file/d/1375H_YpkqVBw7FSQb_-BmXCwku-b7NOx/view?usp=sharing

Fazryan Fareka Riznendi
Author

<record model="ir.ui.view" id="asset_asset_form_view">

<field name="name">asset_asset_form</field>

<field name="model">asset.asset</field>

<field name="inherit_id" ref="asset.assets_form_view" />

<field name="arch" type="xml">

<xpath expr="//form/sheet/notebook/page/group" position="inside">

<group>

</group>

<group>

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</group>

</xpath>

<field name='asset_number' position='replace'>

<field name='asset_number'/>

</field>

<field name='active' position='after'>

<field name='item_type_id' />

</field>

<field name='serial' position='after'>

<field name='many_units' />

</field>

</field>

</record>

La Jayuhni Yarsyah

Can you share screen shoot origin form (before inheriting) ?? i wanna see the structure ,, before it inherited

And i see you wanna inherit form view from module wich named "asset" ,, i try to find the module at odoo source code on github (https://github.com/odoo/odoo/tree/10.0/addons) , but cant find "asset" module. It's your own custom module ??

If it right,, can you share the original form view xml structure...??

La Jayuhni Yarsyah

And What the result looks like , if your xpath like this:

<xpath expr="//form/sheet/notebook/page/group[1]/group[1]" position="after">

<group>

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</group>

</xpath>

Fazryan Fareka Riznendi
Author

now code like this,

<xpath expr="//form/sheet/notebook/page/group" position="inside">

<group>

</group>

<group>

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</group>

</xpath>

and result like in image before...

Fazryan Fareka Riznendi
Author

origin like this image https://drive.google.com/file/d/1mTJx570PVSSy8XnLmSwGaX38xmyzx3lS/view

and this for module,

https://apps.odoo.com/apps/modules/10.0/asset/

I just added a new field to the module, because when I tried to add a field directly to the module it couldn't, so I made simple addons for the inheritance

La Jayuhni Yarsyah

I see on that module repository on -> https://github.com/codup/odoo-eam/blob/10.0/asset/asset_view.xml#L72

There's Empty Group Already defined on origin form view, it post wil be rendered on top right of form

So in this case, can you try to put this code:

<xpath expr="//form/sheet/notebook/page/group[1]/group[2]" position="inside">

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</xpath>

and see the result

Fazryan Fareka Riznendi
Author

Hi La Jayuhni,

Big Thanks, now it's appropriate

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

If you are looking to inherit and add new custom fields to the model asset.asset , what you have done seems to be fine, if there is an issue in the same, please post the issue or update the question with the error message.

Additional field to existing view

Thanks


1
Avatar
Discard
Fazryan Fareka Riznendi
Author

Hello, Thanks for response

there was no error, but the addons field that I added was not in the 'Info' table and grouped there. but instead adds the fields below.

and essentially I want to add fields with new groups next to existing groups,

regards.

Fazryan Fareka Riznendi
Author

if you are confused, you can see this picture for what I mean;

https://drive.google.com/file/d/1mTJx570PVSSy8XnLmSwGaX38xmyzx3lS/view?usp=sharing

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
[SOLVED] How to Hide or Delete Trash Icon in One2many field Solved
python python2.7 odoo odoo10
Avatar
Avatar
2
Aug 25
13030
Filter value 2 field of Many2one
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
5
Sep 20
7077
Filter field domain one2many to many2one Solved
python python2.7 odoo odoo10
Avatar
Avatar
1
Dec 19
10426
How to calculate the value of results in one2many field
python python2.7 odoo odoo10
Avatar
Avatar
1
Jan 19
7255
Generate XLSX(Excel) report in odoo 10 from custom module?
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
2
Jul 18
15446
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