I've been trying to inherit the delete/backspace button onClick() function for the last 6 days with no luck I really need help with this
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ờ
thank you muhammed you saved my day
If answer help full for you kindly accept it as a answer so other will save time
sorry Muhammad but I don't know how to do that, if it needs karma I don't have any
In Odoo 14, you can inherit the delete button in a few different ways. Here are two options:
Using the ir.actions.act_window model:
You can override the ir.actions.act_window model and define a new action for the delete button. Then, you can specify the new action in the form_view_id or tree_view_id field in your view. Here's an example of how you might do this:
from odoo import api, fields, models
class MyDeleteAction(models.Model):
_inherit = 'ir.actions.act_window'
def delete(self):
# Add your custom delete code here
return super().delete()
class MyModel(models.Model):
_name = 'my.model'
name = fields.Char(string='Name')
def action_delete(self):
return {
'name': 'Delete',
'type': 'ir.actions.act_window',
'res_model': self._name,
'view_mode': 'form',
'view_type': 'form',
'target': 'new',
'context': {'delete_custom': True},
'custom_button_delete': True,
}
Using JavaScript:
You can also override the delete button using JavaScript. To do this, you'll need to define a new button in your view and then use JavaScript to attach the delete action to the button. Here's an example of how you might do this:
odoo.define('my_module.delete_button', function (require) {
"use strict";
var ListController = require('web.ListController');
ListController.include({
renderButtons: function () {
this._super.apply(this, arguments);
if (this.$buttons) {
this.$buttons.on('click', '.o_list_button_delete', this._onDeleteRecord.bind(this));
}
},
_onDeleteRecord: function (event) {
event.preventDefault();
// Add your custom delete code here
this._super.apply(this, arguments);
},
});
});
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 | |
---|---|---|---|---|
|
1
thg 10 23
|
1949 | ||
|
1
thg 10 24
|
1412 | ||
|
1
thg 6 23
|
8282 | ||
|
1
thg 5 19
|
2746 | ||
|
1
thg 12 17
|
4778 |