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

Create a custom Filter for relational object

By
Faheem Khan
on 9/1/15, 4:46 AM 613 views

I want to create a custom filter for a relational field as below.

In account.voucher model I need to filter queries based on customer tag and salesperson (category_id and user_id in res.partner), how can I achieve this task in debug view.

Same situation in sale order tree view. Filter sale orders based on customer tag (category_id in res.partner).

 Edit>>

EXPLAINATION

Customer A ~ F have a tag ('category_id' field in partner model) 'Urban Customer'.

Customer G ~ Z have a tag ('category_id' field in partner model) 'Rural Customer'.

Now I want to search payments recieved from 'Urban customer' only in "customer Payment" ("account_voucher" model), same as for 'rural customer'.

Below is an image for customer category.

Hope you got my point.


You can add filter in search view. Like sample http://preview.tinyurl.com/ng7gzcl

Zahin
on 9/1/15, 8:30 AM

This is not the answer. I already know how to access debug mode. Question is how to create this specific filter where model is account.voucher and filter should come from partner tag. I need syntax.

Faheem Khan
on 9/1/15, 8:48 AM
2

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
On 9/1/15, 11:03 AM

Hi Faheem,

Customer filter is already there inside the filters.

Do you want to set default filter as customer when you see any vouchers like customer payment ?

So by applying default filter you have to override the Action of Customer Payment to Set Default filter as Customer. so your vouchers will be filtered/ grouped by customers.

Same thing you can apply for Supplier Payment.

These stuff you will find inside account_voucher module.

Here is the syntax to apply default filter this this line inside the existing actions or by overrding action in your module.

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

If i goes in wrong way than please give more description about your question.

Hope this might help.

Rgds,

Anil.


Thanks for your help but it could not help me. I have updated my question to describe my problem in depth. Please read it again and guide me to solve the issue..

Faheem Khan
on 9/1/15, 11:52 AM

@Faheem: If you are talking about base category field than it is many2many field you can't directly group with many2many field. or else add your field as many2one and add it as filter by overriding search view than your customer will be filtered base on that field.

Anil R. Kesariya
on 9/1/15, 1:05 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: 9/1/15, 4:46 AM
Seen: 613 times
Last updated: 9/1/15, 11:50 AM