How do I extend a model and add some fields and social networking:
For example, I have a class called student:
class Student(models.Model):
_name = 'student'
name = fields.Char(string='name')
How do I extend this model to add new fields and social network feature?
My first try is something like this:
class StudentExtension(models.Model):
_name = 'student'
_inherit = ['student','mail.thread']
form = fields.Char(string='Form')
age = fields.Integer(string='Age')
My question is: Is this the right way to extend the student class? What effect does making the '_name' same as super class have? I tried to extend the Student class without including a _name and I keep getting an error. any help will be appreciated
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ờ
3
Trả lời
3261
Lượt xem
Hi @Sehrish
My question was how do you extend the original class and add social network features to it? You only extended the class but did not show how to add the mail.thread feature to it.class Student(models.Model):
_inherit = 'student'
# we inherited student model and created two new fields in that model.
field_1 = fields.Char(required=True,string="Field One")
field_2 = fields.Boolean(default=False,string="Field Two")
Reference: \http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html
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 1 22
|
2073 | ||
|
1
thg 7 15
|
3383 | ||
|
2
thg 3 15
|
5805 | ||
|
0
thg 3 15
|
4688 | ||
|
4
thg 2 25
|
931 |