Where can I find Default code for Create/Read/Update/Unlink methods and how to override them?
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ờ
1
Trả lời
3745
Lượt xem
Hi, there,
You can inherit the class and rewrite the 4 methods.
Try this(use the sale.order module and take create and write methods for example):
class sale_order_improved(models.Model):
_inherit = ['sale.order']
_order = "name desc"
@api.model
def create(self, vals_list):
_logger.info('---- customer created ----')
_logger.info('---- customer created vals_list ----' + str(vals_list))
order_flag = ''
if 'packaging_ids' in vals_list.keys():
for items in vals_list['packaging_ids']:
order_flag = ','.join(map(str, items[2]))
vals_list.update({'order_flag': order_flag})
res = super().create(vals_list)
return res
def write(self, vals_list):
_logger.info('---- customer updated ----')
_logger.info('---- customer updated vals_list ----' + str(vals_list))
order_flag = ''
if 'packaging_ids' in vals_list.keys():
for items in vals_list['packaging_ids']:
order_flag = ','.join(map(str, items[2]))
vals_list.update({'order_flag': order_flag})
res = super().write(vals_list)
_logger.info('---- customer updated res ----' + str(res))
return res
more references:
https://www\.youtube\.com/watch\?v=sOrCZItpw_4
https://www\.youtube\.com/watch\?v=_\-fs_NBeOLI
https://www.youtube.com/watch?v=v8sXFUi1SH4
Hope it is useful.
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 11 15
|
6007 | ||
|
0
thg 11 15
|
13 | ||
|
1
thg 10 22
|
1895 | ||
How to override an overrided method
Đã xử lý
|
|
3
thg 9 22
|
13548 | |
|
3
thg 8 22
|
4369 |