This question has been flagged
3 Replies
3561 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?

Avatar
Discard
Best Answer

Hi,

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

Thanks

Avatar
Discard
Best Answer

Hi!! Maarten,

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

<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'))]"/>
Avatar
Discard
Author Best Answer

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.

Avatar
Discard