跳至內容
選單
此問題已被標幟
1 回覆
7929 瀏覽次數

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?

頭像
捨棄
最佳答案

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

頭像
捨棄

Thanks Sir!

相關帖文 回覆 瀏覽次數 活動
2
8月 23
3153
3
4月 23
2252
3
12月 22
33764
1
3月 15
4990
7
12月 23
26200