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ợ

Problem creating many2many relationship with product.template

Đă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ờ
2 Trả lời
7532 Lượt xem
Ảnh đại diện
Nathan Beck

I am trying to create a module that allows me to assign products to categories determined by external websites (for example Amazon and eBay categories). Each external category can have many products in it, and each product can be in many categories, one for each external site. Everything works until I try to create a many2many relationship between my external_categories and product.template.

My external_categories class looks a lot like the category class in product, it's name is: _name = "external_categories.category"

The class I am trying to create the many2many relationship in is:

class product_template(osv.osv):
    _inherit = "product.template"
    _columns = {
        'ext_cat_prod_ids': fields.many2many('external_categories.category', 'ext_cat_prod_rel', 'prod_id', 'ext_cat_id', 'External Categories'),
    }

product_template()

I know that I am inheriting product.template, and in the XML sample below I am using the model product.product. I have tried every combination of the two (product.template and product.product) in both locations without luck.

I am trying to add a tab to the product page on the front end. In this tab I will be able to add the product to multiple categories, my XML is:

<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">6</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="External Categories">
                        <group name="properties">
                            <group>
                                <field name="ext_cat_prod_ids" colspan="2" widget="many2many_tags"/>
                            </group>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

When I try to install the module I get an error, this is from the log:

2014-07-27 19:33:46,736 1396 ERROR newVeroTemp openerp.osv.orm: Can't find field 'ext_cat_prod_ids' in the following view parts composing the view of object model 'product.product':
 * product.normal.form.inherit

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model
2014-07-27 19:33:46,736 1396 ERROR newVeroTemp openerp.addons.base.ir.ir_ui_view: Can't render view  for model: product.product
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 126, in _check_render_view
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\stock\product.py", line 441, in fields_view_get
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 2278, in fields_view_get
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 1955, in __view_look_dom_arch
except_orm: ('View error', u"Can't find field 'ext_cat_prod_ids' in the following view parts composing the view of object model 'product.product':\n * product.normal.form.inherit\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model")
2014-07-27 19:33:46,740 1396 ERROR newVeroTemp openerp.tools.convert: Parse error in file:///C:/Program Files (x86)/OpenERP 7.0-20140622-231040/Server/server/openerp/addons/external_categories/external_categories.xml:142: 
<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">6</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="External Categories">
                        <group name="properties">
                            <group>
                                <field name="ext_cat_prod_ids" colspan="2" widget="many2many_tags"/>
                            </group>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\convert.py", line 852, in parse
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\convert.py", line 819, in _tag_record
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_model.py", line 971, in _update
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 103, in create
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 4551, in create
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 1562, in _validate
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2014-07-27 19:33:46,740 1396 ERROR newVeroTemp openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

Thank you in advance for any help our guidence you can provide in the use of many2many relationships.

 

-1
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Nathan Beck
Tác giả Câu trả lời hay nhất

Thank you Jagdish Panchal. I tried your code. Unfortunately, I still get basically the same error: Can't find field 'ext_cat_prod_ids' in the following view parts composing the view of object model 'product.product'

-- UPDATE, PROBLEM SOLVED --

I updated Odoo from 7 to 8 and everything works fine now with the code exactly as it was before (in the original questions). It must be something wrong with Odoo 7 that was causing the problem.

0
Ảnh đại diện
Huỷ bỏ
Jagdish Panchal

I have update ans please try it.

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

Hi,

Try below code

Py file

class product_product(osv.osv):
    _inherit = "product.product"
    _columns = {
        'ext_cat_prod_ids': fields.many2many('external_categories.category', 'ext_cat_prod_rel', 'prod_id', 'ext_cat_id', 'External Categories'),
    }

product_product()

xml file

<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">6</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="External Categories">
                        <group name="properties">
                            <group>
                                <field name="ext_cat_prod_ids" colspan="2" widget="many2many_tags"/>
                            </group>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

 

 

 

0
Ả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ý
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