in contact only display customer detail user and employee no need to display in in contact tree after applying compnies filter it work but i want to do it by code
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
You can override the res.partner model to add a domain filter that only displays customer contacts in the tree view.
from odoo import models, fields, API
class ResPartner(models.Model):
_inherit = 'res.partner'
# Adding a method to return a domain that filters out users and employees
@api.model
def _search_default_customer(self):
return [('customer_rank', '>', 0), ('employee', '=', False), ('user_ids', '=', False)]
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(ResPartner, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
if view_type == 'tree':
doc = etree.XML(res['arch'])
for node in doc.xpath("//tree"):
node.set('domain', "[('customer_rank', '>', 0), ('employee', '=', False), ('user_ids', '=', False)]")
res['arch'] = etree.tostring(doc, encoding='unicode')
return res
You can also customize the tree view directly in XML by adding a domain to filter out non-customer contacts.
<record id="view_partner_tree_
<field name="name">res.partner.tree.
<field name="model">res.partner</
<field name="arch" type="xml">
<tree string="Customers" domain="[('customer_rank', '>', 0), ('employee', '=', False), ('user_ids', '=', False)]">
<field name="name"/>
<field name="phone"/>
<field name="email"/>
<field name="city"/>
<field name="country_id"/>
</tree>
</field>
</record>
To ensure this customized view is used by default, you can override the existing tree view for res.partner
.
<record id="base.view_partner_tree" model="ir.ui.view">
<field name="name">res.partner.tree</
<field name="model">res.partner</
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="domain">[('customer_
</tree>
</field>
</record>
Hope it helps
Hi Sheetal,
Kindly check this custom-built Odoo application for "Hide Contact and Employee"
https://apps.odoo.com/apps/modules/17.0/contact_hr_rule
Hope it helps!
Hi shital,
you could add the domain is_company=true fo show companys only.
{ record id="contacts.action_contacts" model="ir.actions.act_window" }
{ field name="domain" }[("is_company","=",True)),("maybe_some_other_domains","=",False)]{ /field }
{ /record }
Note: you'll have to remove the Filter "Individual", too as long you want to hide them here, too.
regards
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire