This question has been flagged
2 Replies
3751 Views

Hi,


we need to create a domain filter that shows customers that has no sales order attached. 

We have tried filtering on odoo sales order = 0. But it does not seem to work. Anyone that can help?

Avatar
Discard

Hi,

I see it is python. Where is this file located?

Check the file addons/sale/models/res_partner.py line no 11

Author

Hi,

whenever we are trying to edit the .py file and restart server it goes to error 500.

are we doing anything wrong in that instance? should we edit otherwise?

Best Answer

Hi,

By default in the Odoo, there is a smart button in the Partner Form showing the number of sales of the Customer.


This field is a computed field by default so it won't be available in the filter.


To get it in the filter we have to add store=True attribute along with this field.

class ResPartner(models.Model):
_inherit = 'res.partner'

sale_order_count = fields.Integer(compute='_compute_sale_order_count',
                    string='# of Sales Order', store=True)

Once store attribute is added to the above field, now in the partner form filter,




Now you will get the customer with 0 Sales.




Thanks

Avatar
Discard
Author

Hi,

whenever we are trying to edit the .py file and restart server it goes to error 500.

are we doing anything wrong in that instance? should we edit otherwise?