Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 开发与实施交流
  4. 向模型添加字段时,升级的时候报这个错误,求解

向模型添加字段时,升级的时候报这个错误,求解

Scheduled Pinned Locked Moved Odoo 开发与实施交流
2 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    billchen0769
    wrote on last edited by
    #1

    跟着《Odoo14开发指南学习笔记》向模型添加字段时,升级的时候报这个错误!
    求大佬指教,感谢。

    操作无法完成:

    • 创建/更新: 未设置强制字段.
    • 删除: 另一个模型要求删除记录。如果可能的话,把它存档。

    模型: Fields (ir.model.fields), 字段: Field Type (ttype)

    这是源代码
    from odoo import models, fields

    class LibraryBook(models.Model):
    _name = 'library.book'
    _description = '馆藏图书'
    _order = 'date_release desc, name'
    _rec_name = 'short_name'
    name = fields.Char('书名',
    required=True)
    short_name = fields.Char('简称',
    required=True, index=True)
    notes = fields.Text('内部备注')
    state = fields.Selection(
    [('draft', '不可用'),
    ('available', '可用'),
    ('lost', '丢失')],
    '状态',
    default="draft")
    description = fields.Html('描述', sanitize=True, strip_style=False)
    cover = fields.Binary('图书封面')
    out_of_print = fields.Boolean('已停印')
    date_release = fields.Date('出版日期')
    date_updated = fields.Datetime('最后更新时间')
    pages = fields.Integer('页数',
    groups='base,group_user',
    states={'lost': [('readonly', True)]},
    help='图书总页数',
    company_dependent=False)
    reader_rating = fields.Field(
    '读者评分',
    digits=(3, 1),
    # 可选精度(全部位数, 小数位数),
    )
    # author_ids = fields.Many2many('res.partner', string='作者')

    馆藏图书窗体 library.book
    B 1 Reply Last reply
    0
    • B billchen0769

      跟着《Odoo14开发指南学习笔记》向模型添加字段时,升级的时候报这个错误!
      求大佬指教,感谢。

      操作无法完成:

      • 创建/更新: 未设置强制字段.
      • 删除: 另一个模型要求删除记录。如果可能的话,把它存档。

      模型: Fields (ir.model.fields), 字段: Field Type (ttype)

      这是源代码
      from odoo import models, fields

      class LibraryBook(models.Model):
      _name = 'library.book'
      _description = '馆藏图书'
      _order = 'date_release desc, name'
      _rec_name = 'short_name'
      name = fields.Char('书名',
      required=True)
      short_name = fields.Char('简称',
      required=True, index=True)
      notes = fields.Text('内部备注')
      state = fields.Selection(
      [('draft', '不可用'),
      ('available', '可用'),
      ('lost', '丢失')],
      '状态',
      default="draft")
      description = fields.Html('描述', sanitize=True, strip_style=False)
      cover = fields.Binary('图书封面')
      out_of_print = fields.Boolean('已停印')
      date_release = fields.Date('出版日期')
      date_updated = fields.Datetime('最后更新时间')
      pages = fields.Integer('页数',
      groups='base,group_user',
      states={'lost': [('readonly', True)]},
      help='图书总页数',
      company_dependent=False)
      reader_rating = fields.Field(
      '读者评分',
      digits=(3, 1),
      # 可选精度(全部位数, 小数位数),
      )
      # author_ids = fields.Many2many('res.partner', string='作者')

      馆藏图书窗体 library.book
      B Offline
      B Offline
      billchen0769
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Tags
      • Popular
      • Users
      • Groups