Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to use Domain in tree view?

By
Arjun Khode
on 3/17/15, 5:40 AM 3,590 views

Hi, I have inherited res.partner in my python code and added a boolean field called is_investor, which tells us that the partner is an 'investor'.

In XML in base.view_partner_tree, which displays all the types of partners, I want to display only those records for whom is_investor is true.

I tried to add a domain like "[('is_investor', '=', True)]" to the 'display_name' field but it didn't work because Odoo is still taking the original parent view definition.

Here is my code:

  <record id="base_view_partner_tree" model="ir.ui.view">       
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_tree"/>
            <field name="arch" type="xml">
                <field name="display_name" domain="[('is_investor', '=', True)]"/>

            </field>                       
        </record>

Despite this code, it is still showing me all of the partners including customers, suppliers, etc. I only want to see investors in this Tree view.

Can someone tell me how to add this domain successfully?

2
Arjun Khode
On 3/17/15, 6:39 AM

Thanks for the answer. I figured it out.

I inherited the search view of res.partner and added my own filter like this:


<record id="base_view_res_partner_filter" model="ir.ui.view">

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_res_partner_filter"/>

<field name="arch" type="xml">

<filter string="Salesperson" position="after">

<filter string="Investor" name="investor" domain="[('is_investor', '=', True)]"/>

</filter>

</field>

</record>


Then, in my corresponding action for 'investor' menu, I defined this line

<field name="context">{'search_default_investor':1}</field>


Note that the search_default_investor is named that way because the syntax is:

{'search_default_searchFilterName':1}

It should not be search_default_is_investor because is_investor is a field name not the name of a filter.


Someone reading this might also find this question useful:

https://www.odoo.com/forum/help-1/question/how-to-create-own-filter-and-apply-it-by-default-75280


Hope this helps someone. And thanks for the help Vasanth!

1

Vasanth

--Vasanth--
3458
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
On 3/17/15, 6:02 AM

you can use the search view instead of tree view for this


<search string=" ===="> 

<filter string="Investor" name="investor" icon="terp-personal" domain="[('is_investor','=','True')]" />

   </search>

By using this, you can find a filter in the search view called"Investor" and by clicking it, you can get only the records which the investor is true.

If you want this filter as default means, use this following code:


<record id="action_account_period_tree" model="ir.actions.act_window">

=====================

==========

<field name="context">{'search_default_investor': 1}</field>

  </record>


All the best


How to set domain in action view if i must get some value in function ?

Pichchanok Nuchpan
on 9/19/16, 4:36 AM
0

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 3/17/15, 6:44 AM

Hello Arjun,

You were adding domain at wrong place. If you want to limit your data by particular domain wise in list view then you shall add domain in Action. You can set Domain & Context accordingly as per need in Window Action. 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/17/15, 5:40 AM
Seen: 3590 times
Last updated: 3/17/15, 6:53 AM