I want to store only one record in a table and I have to show an error message when clicked on create button in tree view , if tried to enter another record . How to over ride the create button and display custom error message.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
1
回复
3841
查看
Hi,
You can try like this,
@api.model
def create(self, vals):
existing_records = self.search([])
if len(existing_records) >1:
raise ValidationError(_("Cannot Create More Than 1 Record"))
res = super(ClassName, self).create(vals)
return res
Thanks
Hi Niyas, how to add a new button after the create button in Odoo16?
相关帖文 | 回复 | 查看 | 活动 | |
---|---|---|---|---|
|
3
7月 24
|
2723 | ||
|
2
6月 22
|
2885 | ||
|
0
7月 17
|
4489 | ||
|
0
6月 15
|
3949 | ||
|
0
3月 15
|
4082 |