odoo_dev 开发培训作业:图书管理系统
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

25 行
693B

  1. from odoo import api, fields, models
  2. class BookCategory(models.Model):
  3. _name = 'library.book.category'
  4. _description = 'Book Category'
  5. _parent_store = True
  6. name = fields.Char(translate=True, required=True)
  7. # Hierarchy fields
  8. parent_id = fields.Many2one(
  9. 'library.book.category',
  10. 'Parent Category',
  11. ondelete='restrict')
  12. parent_path = fields.Char(index=True)
  13. # Optional but good to have:
  14. child_ids = fields.One2many(
  15. 'library.book.category',
  16. 'parent_id',
  17. 'Subcategories')
  18. highlighted_id = fields.Reference(
  19. [('library.book', 'Book'), ('res.partner', 'Author')],
  20. 'Category Highlight'
  21. )
上海开阖软件有限公司 沪ICP备12045867号-1