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

I am trying out an example of "Using abstract models for reusable model features"


My code is showing an error:

raise TypeError("Model %r inherits from non-existing model %r." % (name, parent))
TypeError: Model 'library.book' inherits from non-existing model 'base.archive'. - - - 


My Code:

class BaseArchive(models.AbstractModel):

    _name = 'base.archive'
    active = fields.Boolean(default=True)
    def do_archive(self):
        for record in self:
            record.active = not record.active

class LibraryBook(models.Model):
    _name = 'library.book'
    _inherit = ['base.archive']

頭像
捨棄
最佳答案
--- sory
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
3月 23
6878
1
7月 25
2638
4
3月 24
3512
1
10月 23
5441
0
5月 23
2335