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ợ

How to completely replace res.partner.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ờ
viewsv7
3 Trả lời
22516 Lượt xem
Ảnh đại diện
David Dean

I would like to replace the default res.partner.form view with a completely new view from a simple module I've created.

I want to replace instead of inherit because I don't just want to change the fields, I also want to change the HTML and other markup around those fields. Inheriting the form and adjusting individual fields won't give me the control I'm looking for.

I've managed to create a module with a new view, load the module into OpenERP and confirmed the view is registered but my changes are not visible. When I enable debug mode and look at "Manage Views" the "View Type" is "undefined" and res.partner is still using the default view.

Can anyone point me in the direction of where I'm going wrong? I've spent hours reading the documentation and Googling but still not managed to get this working.

andromeda_customer_form.py

from osv import osv, fields
from tools.translate import _

class andromeda_customers(osv.osv):

  _inherit = 'res.partner'

  _columns = {
    'andromeda_customer_type': fields.selection([('individual','Individual'),('business','Business'),('charity','Charity / Non-Profit'),('government','Government')],'Customer Type'),
    'andromeda_business_type': fields.selection([('sole_trader','Sole Trader'),('limited','Limited Company / Limited Liability Partnership'),('partnership','Partnership'),('other','Other')],'Business Type'),
    'andromeda_customer_title': fields.selection([('mr','Mr'),('mrs','Mrs'),('miss','Miss'),('ms','Ms'),('dr','Dr'),('prof','Prof'),('rev','Rev'),('sir','Sir')],'Title'),
    'andromeda_customer_firstname': fields.char('First name', size=16),
    'andromeda_customer_lastname': fields.char('Last name', size=16),
    'andromeda_customer_phone': fields.integer('Contact number', size=16),
    'andromeda_customer_email': fields.char('E-mail address', size=16),
  }

andromeda_customers()

andromeda_customer_form.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="andromeda_customer_form">
      <field name="name">res.partner.form</field>
      <field name="model">res.partner</field>
      <field name="priority" eval="1"/>
      <field name="arch" type="xml">
          <field name="andromeda_customer_type" />
          <field name="andromeda_business_type" />
          <field name="andromeda_customer_title" />
          <field name="andromeda_customer_firstname" />
          <field name="andromeda_customer_lastname" />
          <field name="andromeda_customer_phone" />
          <field name="andromeda_customer_email" />
      </field>
    </record>
  </data>
</openerp>

Screenshot: I don't have enough karma to post links, so replace ** with the http prefix to view the image.

**dl.dropboxusercontent.com/u/41195444/openerp.png

1
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Jasad Moozhiyan
Câu trả lời hay nhất

Hi David Dean,

There are two solutions:

  1. Give the same id of partner form to your form.

ie,

<record model="ir.ui.view" id="base.view_partner_form">
      <field name="name">res.partner.form</field>
      <field name="model">res.partner</field>
      <field name="priority" eval="1"/>
      <field name="arch" type="xml">
          <field name="andromeda_customer_type" />
          <field name="andromeda_business_type" />
          <field name="andromeda_customer_title" />
          <field name="andromeda_customer_firstname" />
          <field name="andromeda_customer_lastname" />
          <field name="andromeda_customer_phone" />
          <field name="andromeda_customer_email" />
      </field>
    </record>

So it will replace the view with same id.

  1. Change the view_id in partner form menu.

ie,

<record id="base.action_partner_form_view2" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="andromeda_customer_form"/>
            <field name="act_window_id" ref="action_partner_form"/>
        </record>

So here, the action inheriting, and it takes your form view.

1
Ảnh đại diện
Huỷ bỏ
Levi Bensley

I tried the top method, but for the sale view, but then couldn't update the base sale module or modules such as sale_purchase do to a missing field (one that i added in my custom module)

Ảnh đại diện
Paty L L
Câu trả lời hay nhất

Hello David.

Did you manage to replace completely the res_partner_form_view? Can it be done? Im having issues with this topic, and don't see a formal answer.

Greetings.

Nestor

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
AJ Schrafel Paper Corp
Câu trả lời hay nhất

You just tossed the fields into the XML.

You need to wrap the type of view it is around you fields.

<field name="arch" type="xml">
    <form string="You need to include this around your fields to define it as a form" version="7.0">
        <your fields>
    </form>
</field>
0
Ảnh đại diện
Huỷ bỏ
David Dean
Tác giả

Hi - thanks for your reply! Wrapping the fields inside "<form string="Partners">" has fixed the problem where the "View Type" was "undefined". It's now correctly listed as Form. But I still have the problem where view "res.partner.form" is taking precedence over my replacement view (as-per the screenshot). How can I force my new view to be used by default? Thanks again, I appreciate your help.

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
What is the different between col and colspan? Đã xử lý
views v7
Ảnh đại diện
Ảnh đại diện
1
thg 10 24
70337
What does the "no_open : True" widget option do in a view definition? Đã xử lý
views v7
Ảnh đại diện
Ảnh đại diện
2
thg 12 23
26786
How do I search by country_id in view? Đã xử lý
views v7
Ảnh đại diện
Ảnh đại diện
1
thg 10 21
10191
How to edit/consult one2many without popup?
views v7
Ảnh đại diện
Ảnh đại diện
1
thg 3 15
7466
Is it possible to join several tables in one view
views v7
Ảnh đại diện
Ảnh đại diện
1
thg 3 15
7347
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