Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
treeviewxmlforminheritanceodoov11
3 Odgovori
7900 Prikazi
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
Opusti
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
Avtor

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
Opusti
Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
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
okt. 23
3774
how to get current value of a record line in a XML tree view
action module treeview xml odoov11
Avatar
1
okt. 18
8629
Difference between xpath and field with only position="replace"
inheritance odoov11
Avatar
Avatar
1
nov. 22
4204
OdooV11 : Hierarchical Tree view in Odoo 11 ?
treeview odoov11
Avatar
Avatar
Avatar
2
jul. 18
10762
Prototype inheritance. Solved
inheritance odoov11
Avatar
Avatar
2
mar. 18
5574
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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