I dont want to create data because i want to make error checking before it create the data.. So it show the notification before creating the data
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
If you are looking to add some constrains before saving or creating new record, you can use the constrains in odoo or override the create method and show the warning.
See how to use Constrains:
@api.constrains('model_id')
def _check_model_name(self):
# Don't allow rules on rules records (this model).
if any(rule.model_id.model == self._name for rule in self):
raise ValidationError(_('Rules can not be applied on the Record Rules model.'))
Overriding Create Method:
@api.model
def create(self, values):
if not values.get('login', False):
action = self.env.ref('base.action_res_users')
msg = _("You cannot create a new user from here.\n To create new user please go to configuration panel.")
raise exceptions.RedirectWarning(msg, action.id, _('Go to the configuration panel'))
user = super(Users, self).create(values)
# Auto-subscribe to channels
self.env['mail.channel'].search([('group_ids', 'in', user.groups_id.ids)])._subscribe_users()
return user
So depending On your use case, either you can show some warning or notification if some conditions/criteria is not satisfied from the create method or from the constrains.
Thanks
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 3 20
|
3821 | ||
|
0
thg 6 22
|
856 | ||
|
1
thg 3 20
|
4497 | ||
|
0
thg 3 23
|
1116 | ||
|
1
thg 6 22
|
1505 |