Odoo Help


Filter Customers based on confirmed sales orders

Maarten Van Speybroeck
on 18-1-3 上午11:38 357 views

On Odoo 10

I am trying to create a custom filter for the sales>customers overview, which should only show customers who have actually bought something at least once. I am trying with

[[u'customer', u'=', 1], [u'parent_id', u'=', False], [u'is_company', u'=', 1], [u'sale_order_count', u'>', 0]]
Also tried using the field  "total_invoiced > 0", but every attempt gives back all customers. What am I doing wrong here?


Niyas Raphy

--Niyas Raphy--
| 5 6 9
Calicut, 印度
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to contact :  niyasraphyk@gmail.com

Niyas Raphy
On 18-1-3 下午11:51


I think you can do it using the sale_order_count . I have just checked it from the user interface its working fine.

Filters - > Add custom filter -> , set sale order not equal to 0

Adding filter,

Then the customers having at least one sale will be displayed


Dishan Madushanka
On 18-1-3 下午11:41

Hi!! Maarten,

This is my code and try like this,in my code only filtered last 30 days customers.get some idea from this.

<filter string="Last 30 Days" name="prev_month" domain="[('date_order','&gt;=',(context_today()-relativedelta(months=1)).strftime('%Y-%m-01')),('date_order','&lt;',time.strftime('%Y-%m-01'))]"/>
Maarten Van Speybroeck
On 18-1-4 上午8:09

Thanks, Niyas. But it does not really do what I would expect. In your filter "customers" is also active, which means that only customers without a parent company are visible (so no contacts linked to the customer company). When the sales orders are directed to a contact rather than its company, the filter "sales_order_ids != 0 does not work anymore because sales order count is apparently not transferred from contact to parent company.

Because all our sales orders are addressed to contacts, your proposed filter gives zero results with me. When I remove the filter "customers" however, it works and list all the contacts (but not the parent companies to which the contacts belong). When I group by company then, it gives the results I was looking for.

Strange though that sales order count is not transferred to the actual customer (company), but is only linked to the contact.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 18-1-3 上午11:38
Seen: 357 times
Last updated: 18-1-4 上午8:10