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ợ

Filter using domain in a many2many relation 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ờ
domainmany2many
9 Trả lời
50221 Lượt xem
Ảnh đại diện
Alessandro Pillan

Hi all, I'm trying to understand how domain works in tree view for a many2many relationship in OpenERP 7.0. This is a dummy class Places:

class place_type(Model):
    _name = "place.type"
    _description = "Place Type"
    _columns = {
        'name': fields.char('Name', size=16, required=True),
    }
    _order = 'name asc'

place_type()

class place(Model):
    _name = "place"
    _description = "Place"
    _columns = {
        'name': fields.char('Name', size=64, required=True),
        'type': fields.many2one('place.type', string='Type'),
    }
    _order = 'name asc'

place_type()

class res_partner(Model):
    _inherit = 'res.partner'
    _columns = {
        'place_ids': fields.many2many('place', string="Dummy Places"),
    }

res_partner()

I'm just adding to partners some places defined by a name and a type, this is my view:

<!-- places page addition to partner form -->
<record model="ir.ui.view" id="view_partner_form_with_dummy_places">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="(sheet/notebook/page)[last()]" position="after">
                <page string="Dummy Places">
                    <field name="place_ids" domain="('type', '=', 4)"/>
                </page>
            </xpath>
        </field>
</record>

I've tried in many ways to make domain working, in this case "4" is a real type id.
I also tried to insert obviously wrong domain statements, without getting any feedback error neither in server log nor in javascript console.
Is it completly ignored?
Latter, what I want to achieve is dynamically filtering partner places by a select field , is it possible?
I really appreciate any help!

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

I want to use partner's name from 'partner_ids' field which is a 'many2many' field in the 'partner.ledger.webkit' model, in the attachment prefix for the report 'Partner Ledger Report' example 'object.company_id.name.pdf'. Please help!

Ảnh đại diện
René Schuster
Câu trả lời hay nhất

The domain is a list of tuples, so use a list:

<field name="place_ids" domain="[('type', '=', 4)]"/>

 

Regards.

3
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Andre de Kock
Câu trả lời hay nhất



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

Hi Allessandro,

Update:

Domain is not a valid attribute for the field object in xml view.

It is however possible to define a functional field to filter a x2many field. Further information can be found in the nice Andreas Brueckl answer.


Have you tried: domain="('type.id', '=', 4)" instead of: domain="('type', '=', 4)" ?

For the dynamic filtering, you may try something like:

class res_partner(Model):
    _inherit = 'res.partner'
    _columns = {
        'type_id': fields.many2one('place.type', string='Type'),
        'place_ids': fields.many2many('place', string="Dummy Places"),
    }
res_partner()

And in the XML view:

<page string="Dummy Places">
   <field name="type_id" />
   <field name="place_ids" domain="('type.id', '=', type_id)"/>
</page>
1
Ảnh đại diện
Huỷ bỏ
Alessandro Pillan
Tác giả

Domain is still not working, now it doesn't show any record. But when I try to add a new place now it throw an error, it may be helpful:

File "/home/openerp/server/openerp/osv/expression.py", line 582, in check_leaf raise ValueError("Invalid leaf %s" % str(self.leaf)) ValueError: Invalid leaf type.id

Gabriel

Can we have more details on what you are intending to do. Would you like to hide some records of the existing many2many links or filter the Add tree view displayed when adding a new record?

Alessandro Pillan
Tác giả

Yes, sorry, I would like to hide records where type is not equal to something. Next step field type_id added on your view should be a select

Gabriel

It seems that domain is not working when it is defined in XML view. I tried as well by adding a filter through a search view, and unfortunately it does not seems to work neither.

Finally what worked for a similar case where I had to display two times the same one2many field on the same view with different filters was to create two functional fields returning the filtered ids.

In your case one functional field returning the ids of place_ids that have the specified type_id would probably make it.

evon_dun

I want to use partner's name from 'partner_ids' field which is a 'many2many' field in the 'partner.ledger.webkit' model, in the attachment prefix for the report 'Partner Ledger Report' example 'object.company_id.name.pdf'. Please 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
Many2many domain works when click search more but wrong values in dropdown
domain many2many
Ảnh đại diện
0
thg 11 22
80
[SOLVED] Create rule using many2many - how to? Đã xử lý
domain many2many
Ảnh đại diện
1
thg 6 22
8090
Many2many domain not working Đã xử lý
domain many2many
Ảnh đại diện
1
thg 7 21
3504
Many2many domain not working Đã xử lý
domain many2many
Ảnh đại diện
Ảnh đại diện
1
thg 7 21
5013
Domain for Many2many fields
domain many2many
Ảnh đại diện
Ảnh đại diện
1
thg 10 15
11623
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