跳至内容
菜单
此问题已终结
1 回复
2607 查看

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.


形象
丢弃
最佳答案

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


形象
丢弃
编写者

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

编写者

I have tried to make an add-on with your code, but it doesn't work.
I think 'order_ref' may be wrong. Can you give more hints please?

相关帖文 回复 查看 活动
1
11月 20
2314
4
7月 24
15284
1
6月 22
6444
1
4月 22
3276
1
3月 21
7524