Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7950 Lượt xem

We appreciate how one can add 'tracking' = True to various fields in order to record their changes to the chatter feed.

However, there are some fields in built-in models that we would like to add this functionality too.

I think we can re-declare the field in an _inherited model but this can lead to high cohesion between our code and the original source code.  Instead, is there a way to just change the property of an attribute in an inherited way on an existing model?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

To change the property of an existing field, what you can do is that inherit the corresponding model first and,

class AccountAccountType(models.Model):
_name = "account.account.type"
_description = "Account Type"

name = fields.Char(string='Account Type', required=True, translate=True)

Above code is from the account module, suppose if i need to change the field to required to False, what i have to do is that as follows,

class AccountAccountType(models.Model):
_inherit = "account.account.type"

name = fields.Char(required=False)

Thanks

Ảnh đại diện
Huỷ bỏ

Thanks Sir!

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 23
3167
3
thg 4 23
2270
3
thg 12 22
33776
1
thg 3 15
5012
7
thg 12 23
26214