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

Inheritance : Can't see the new field on the form view

Subscribe

Get notified when there's activity on this post

This question has been flagged
treeviewxmlforminheritanceodoov11
3 Replies
7896 Views
Avatar
Mohamed Lamine Lalmi

Hello, odoo devs,

I'm trying to learn inheritance using ODOO 11, I built a simple module that displays TODO-List, after that, i developed another module that is responsible for adding new fields on the first module view (form & view) using inheritance mechanism.  The problem the new fields do not show after installing the second module.

Any help, please ?

The first module python & XML files :

# -*- coding: utf-8 -*-
from odoo import models, fields, api
import logging
_logger = logging.getLogger(__name__)
class TodoTask(models.Model):
    _name = 'todo.task'
name = fields.Char("name", required=True)
active = fields.Boolean("Is active ?", default=True)
is_done = fields.Boolean("Is done ?")
@api.multi
def do_toggle_done(self):
for task in self:
task.is_done = not task.is_done
log_data = str(task.name) + (" is done" if task.is_done else " not done yet")
self.show_log(log_data)
return True
@api.multi
def do_clear_done(self):
dones = self.search([('is_done', '=', 'True')])
dones.write({'active': False})
return True
@api.model
def show_log(self, log_data):
_logger.critical(str(log_data))jdf

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!--Task form view-->
<record model="ir.ui.view" id="view_form_todo_task">
<field name="name">Todo tasks form</field>
<field name="model">todo.task</field>
<field name="arch" type="xml">
<form string="Todo Task">
<header>
<button name="do_toggle_done" type="object" string="Toggle done" class="oe_highlight"/>
<button name="do_clear_done" type="object" string="Clear All Done"/>
</header>
<sheet>
<group name="group_task_info_top">
<field name="name" placeholder="Task's description" required="True"/>
<group name="group_task_info_right">
<field name="is_done"/>
</group>
<group name='group_task_info_left'>
<field name="active" readonly="1"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<!--Task tree view-->
<record model="ir.ui.view" id="view_tree_todo_task">
<field name="name">Todo tasks list</field>
<field name="model">todo.task</field>
<field name="arch" type="xml">
<tree colors="decoration-muted:is_done==True">
<field name="name"/>
<field name="is_done"/>
</tree>
</field>
</record>
<!--Task Search view-->
<record model="ir.ui.view" id="view_search_todo_task">
<field name="name">Todo tasks search</field>
<field name="model">todo.task</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<filter string="Not Done" domain="[('is_done','=',False)]"/>
<filter string="Done" domain="[('is_done','=',True)]"/>
</search>
</field>
</record>
</data>
</odoo>

The second module python & XML files:

# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import ValidationError
class TodoTask(models.Model):
_inherit = 'todo.task'
# Adding new filed
user = fields.Many2one('res.users', string='Responsible')
deadline = fields.Date("Deadline")
# Modifying existing fields
name = fields.Char(help="What needs to be done ?")
# Overriding methods
@api.multi
def do_clear_done(self):
dones = self.search\
([
('is_done', '=', True),
'|',
('user', '=', self.env.uid),
('user', '=', False)
])
for done in dones:
done.write({'active': False})
return True
@api.multi
def do_toggle_done(self):
for task in self:
if task.user != self.env.uid:
raise ValidationError('Only the responsible van do this !')
return super(TodoTask, self).do_toggle_done()

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_form_todo_task_extension" model="ir.ui.view">
<field name="name">Todo Form Extension</field>
<field name="model">todo.task</field>
<field name="inherit_id" ref="todo_app.view_form_todo_task"/>
<field name="arch" type="xml">
<field name='name' postion="after">
<field name="deadline"/>
</field>
<field name='active' postion="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name='active' postion="before">
<field name="user"/>
</field>
</field>
</record>
<record id="view_tree_todo_task_extension" model="ir.ui.view">
<field name="name">Todo Tree Extension</field>
<field name="model">todo.task</field>
<field name="inherit_id" ref="todo_app.view_tree_todo_task"/>
<field name="arch" type="xml">
<field name='name' postion="after">
<field name="deadline"/>
<field name="user"/>
</field>
</field>
</record>
<record id="view_search_todo_task_extension" model="ir.ui.view">
<field name="name">Todo Search Extension</field>
<field name="model">todo.task</field>
<field name="inherit_id" ref="todo_app.view_search_todo_task"/>
<field name="arch" type="xml">
<field name='name' postion="after">
<field name="user"/>
<filter string="All" domain="[('user','in',[uid,False])]"/>
<filter string="My tasks" domain="[('user','in',uid)]"/>
<filter string="Not Assigned" domain="[('user','=',False)]"/>
</field>
</field>
</record>
</data>
</odoo>

0
Avatar
Discard
Samo Arko

do you use the default created files or do you use own named files. If you use own don't forget to add them to __manifest__.py and models/__init__.py. If you have 2 different custom modules don't forget on the second to add the 1st custom module to depends in __manifest__.py.

Odoo will use his own view if you don't define your custom view. Where are actions and menu items in your views?

Mohamed Lamine Lalmi
Author

I check that, and I think that I did it correctly

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

I think the issue is with a typo error.

Check the XML view of 2nd module. You spell position (postion) wrong.

It should be like this:

<field name='name' position="after">
<field name="deadline"/>
</field>

Hope this will help you.

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com  webiste: http://www.erpharbor.com
4
Avatar
Discard
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
How to create a new tree view for inherited(res.users) model without modifying the original view? v16
treeview xml inheritance odoo16features
Avatar
Avatar
1
Oct 23
3771
how to get current value of a record line in a XML tree view
action module treeview xml odoov11
Avatar
1
Oct 18
8620
Difference between xpath and field with only position="replace"
inheritance odoov11
Avatar
Avatar
1
Nov 22
4199
OdooV11 : Hierarchical Tree view in Odoo 11 ?
treeview odoov11
Avatar
Avatar
Avatar
2
Jul 18
10760
Prototype inheritance. Solved
inheritance odoov11
Avatar
Avatar
2
Mar 18
5570
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