Hello, I would like to modify the partner form in order to separate the display of contacts and addresses on 2 distinct tabs. My problem is when displaying the "child_ids" field. How to display only part of the records by filtering them?
Code to display only contact on first tab:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="society_res_partner_form">
<field name="name">society Partner Form Inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority">100</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='company_type']" position="attributes">
<attribute name="readonly">True</attribute>
</xpath>
<xpath expr="//page[1]" position="attributes">
<attribute name="string">Contacts</attribute>
<attribute name="attrs">{'invisible': [('is_company','!=',True)]}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']" position="attributes">
<attribute name="mode">tree</attribute>
<attribute name="domain">[('type', '=', 'contact')]</attribute>
<attribute name="context">{'default_type': 'contact'}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']/kanban" position="replace">
<tree>
<field name="name"/>
<field name="type"/>
<field name="company_type"/>
<field name="city"/>
<field name="email"/>
<field name="phone"/>
</tree>
</xpath>
</field>
</record>
</odoo>
The "<attribute name="domain">[('type', '=', 'contact')]</attribute>" as no effect,
all records are loaded, not just contacts.
Thank you
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
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
3904
Lượt xem
Hello,
As a simple modification of view is not enough, I added two fields. One for storing contact IDs, the other for addresses IDs. Then you have to modify the view to replace the standard tab with the two loaded with the new fields.
------------------resPartner model
from odoo import models, api, fields, _
Class ResPartner(models.Model):
_inherit = 'res.partner'
contact_ids = fields.One2many('res.partner', 'parent_id', string='Contacts',
domain=[('active', '=', True), ('type', '=', 'contact')])
adress_ids = fields.One2many('res.partner', 'parent_id', string='Adresses',
domain=[('active', '=', True), ('type', '!=', 'contact')])
-------------------resPartner view
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="society_res_partner_form">
<field name="name">society Partner Form Inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority">100</field>
<field name="arch" type="xml">
<xpath expr="//page[1]" position="replace">
<page name="contacts" string="Contacts" attrs="{'invisible': [('is_company','!=',True)]}">
<field name="contact_ids" mode="tree" context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_lang': lang, 'default_user_id': user_id, 'default_type': 'contact', 'default_company_type': 'person'}">
[...]
</field>
</page>
<page name="adresses" string="Adresses" attrs="{'invisible': [('is_company','!=',True)]}">
<field name="adress_ids" mode="tree" context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_lang': lang, 'default_user_id': user_id, 'default_type': 'delivery', 'default_company_type': 'person'}">
[...]
</field>>
</page>
</field>
</record>
</odoo>
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 | |
---|---|---|---|---|
|
0
thg 3 22
|
110 | ||
|
3
thg 3 15
|
8821 | ||
|
1
thg 3 15
|
5274 | ||
|
1
thg 7 25
|
2699 | ||
|
0
thg 2 24
|
1524 |