gpt4 book ai didi

python - 属性错误: 'bool' object has no attribute '_fields' - Odoo v8

转载 作者:行者123 更新时间:2023-12-01 02:28:24 30 4
gpt4 key购买 nike

我只是向我的模型添加一些相关字段,其他一些字段可以工作,但对于这个模型,它们不会,这些是我的模型:

class book_block(models.Model):
_name = 'book.block'

name = fields.Char(string="Name")
code = fields.Char(string="Code", size=11)
size_code = fields.Many2one('bsi.book.block.size', string="Size")
text_paper = fields.Many2one('text.paper', string="Text Paper")
n_pages_one_color = fields.Integer(string="N° of pages 1 color")
adnl_n_pages_one_color = fields.Integer(string="Additional N° of pages one color")

class mrp_worksheet_contract(models.Model):
_name = 'mrp.worksheet.contract'

@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('mrp.worksheet.contract') or '/'
return super(mrp_worksheet_contract, self).create(vals)

name = fields.Char('Reference', required=True, index=True, copy=False, readonly='True', default='New')
date = fields.Date(string="Date")
book_block = fields.Many2one('book.block', string="Book Block")
n_pages_one_color = fields.Integer(string="N of pages one color", related="book_block.n_pages_one_color")
adnl_n_pages_one_color = fields.Integer(string="Additional N° of pages one color", related="book_block.adnl_n_pages_one_color")

book_block 字段没问题,问题在于 n_pages_one_coloradnl_n_pages_one_color 字段,它让我感到困惑:

Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\web\controllers\main.py", line 948, in call_button
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\base\module\module.py", line 447, in button_immediate_install
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\base\module\module.py", line 495, in _button_immediate_function
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\modules\registry.py", line 370, in new
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\modules\loading.py", line 355, in load_modules
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\modules\loading.py", line 255, in load_marked_modules
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\modules\loading.py", line 156, in load_module_graph
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\modules\registry.py", line 194, in setup_models
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 372, in old_api
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 3010, in _setup_fields
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\fields.py", line 468, in setup
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\fields.py", line 514, in _setup_related
AttributeError: 'bool' object has no attribute '_fields'

我不明白,它应该可以工作,我没有看到任何问题,甚至 book_block Many2one 字段也很好,所以,这是怎么回事?

有什么想法吗?

最佳答案

不引用 bool (非 bool )字段。错误是从 File "C:\Program Files (x86)\Odoo 8.0-20170914\server.\openerp\fields.py", line 514, in _setup_related 生成的strong>_setup_lated方法,根据源码:设置相关字段的属性。因此,我建议您检查具有相关属性的所有字段。并检查 book_block 模型中是否存在 adnl_n_pages_one_color 字段。

关于python - 属性错误: 'bool' object has no attribute '_fields' - Odoo v8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47106218/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com