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:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
1
الرد
3881
أدوات العرض
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>
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
0
مارس 22
|
110 | ||
|
3
مارس 15
|
8800 | ||
|
1
مارس 15
|
5264 | ||
|
1
يوليو 25
|
2666 | ||
|
0
فبراير 24
|
1501 |