Help

0

order not found warning message

Avatar
Jiashun Chen

Hi, 

When I try to search multiple orders in the order list, if the order does not exist, odoo doesn't show any message like: order XXX not found. So I may think the order is there.

So How to raise a message to notice me? 

Thanks.


Avatar
Discard
1Answer
1
Best Answer

Hi,

For this you can raise a warning message in your custom code if the searched record doesn't exist.

For example:

If you are searching for sale order with name 'order_ref',  you can add as below

from odoo.exceptions import UserError

class SaleOrder(models.Model):
_inherit = 'sale.order'

def search_sale_order(self):
order_id = self.env['sale.order'].search([('name', '=', 'order_ref')])
if not order_id:
raise UserError(_("Order Not Found !"))


Thank you


1Comment
Avatar
Discard
Avatar
Jiashun Chen
-

Hi Mehjabin.
But how to apply this "search_sale_order" function to the search function?