Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

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

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
treeviewxmlforminheritanceodoov11
3 Trả lời
7889 Lượt xem
Ảnh đại diện
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
Ảnh đại diện
Huỷ bỏ
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
Tác giả

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

Ảnh đại diện
Sudhir Arya (ERP Harbor Consulting Services)
Câu trả lời hay nhất

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
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
How to create a new tree view for inherited(res.users) model without modifying the original view? v16
treeview xml inheritance odoo16features
Ảnh đại diện
Ảnh đại diện
1
thg 10 23
3767
how to get current value of a record line in a XML tree view
action module treeview xml odoov11
Ảnh đại diện
1
thg 10 18
8617
Difference between xpath and field with only position="replace"
inheritance odoov11
Ảnh đại diện
Ảnh đại diện
1
thg 11 22
4198
OdooV11 : Hierarchical Tree view in Odoo 11 ?
treeview odoov11
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 7 18
10758
Prototype inheritance. Đã xử lý
inheritance odoov11
Ảnh đại diện
Ảnh đại diện
2
thg 3 18
5569
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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