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

Search filter based on a field from user object

By
Mathieu Laflamme
on 7/21/15, 9:41 AM 469 views

I added a new field in user called current_stock_owner.

My module will filter many views to show only stuff from the current stock owner of the logged user (a stock_owner is added in the relevant objects to match the current_stock_owner):

- Products

- Sales Orders

- Customers

- Etc.

How could I make a search filter to achieve that?

EDIT:

To be more explicit, stock_owner are our direct customers. They have their own products and sales order and their own customers list. When a user change its current_stock_owner, it will shown only relevant data by default.

1
chirag jogi
On 7/24/15, 8:57 AM

Hello ,

you can try like this for search view ,

<!-- search view -->

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

<field name="name">Product Details</field>

<field name="model">product.template</field>

<field name="type">search</field>

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

<search string="Search By Product">

<group expand="0" string="Group By...">

<filter string="Product" domain="[]" context="{'group_by':'product'}"/>

 </group>

</search>

</field>

</record>

<!-- end code of search-->

It makes no sense... how could it work without any reference to my stock_owner and current_stock_owner fields?

Mathieu Laflamme
on 7/24/15, 10:29 AM
0
Bas
On 7/21/15, 10:01 AM

I would try it the other way around. Make a field in Products, Sales Orders, etc, referring to the user who is the current stock owner. Then filter those objects (Products, etc) to only those items where the current logged user is the current stock owner. 

stock_owner isn't a user. It's a company like Mc Donald. Mc Donald has their own products, sales and customers they ship to. So when I select Mc Donald as my default_stock_owner in my user profile, I want to see only Mc Donald product, orders and customers by default, and filter out Burger King and Subway. Does it make sense?

Mathieu Laflamme
on 7/21/15, 12:59 PM

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: 7/21/15, 9:41 AM
Seen: 469 times
Last updated: 7/24/15, 8:57 AM