AttributeError: 'bool' object has no attribute '_fields' - Odoo v8
AttributeError: 'bool' object has no attribute '_fields' - Odoo v8
我只是在我的模型中添加了一些相关字段,其他一些字段可以工作,但是对于这个模型他们不会,这些是我的模型:
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_color
和 adnl_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
字段都可以,所以,怎么回事?
有什么想法吗?
可能您需要从 openerp 导入“_”。像这样:
from openerp.tools.translate import _
不引用布尔(非布尔)字段。错误是从 _setup_related[=16 生成的(来自 tracebak:File "C:\Program Files (x86)\Odoo 8.0-20170914\server.\openerp\fields.py",第 514 行,在 _setup_related 中) =]方法,根据源码:设置相关字段的属性。因此,我建议您检查任何具有相关属性的字段。
并检查 adnl_n_pages_one_color 字段是否存在于 book_block 模型中。
我只是在我的模型中添加了一些相关字段,其他一些字段可以工作,但是对于这个模型他们不会,这些是我的模型:
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_color
和 adnl_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
字段都可以,所以,怎么回事?
有什么想法吗?
可能您需要从 openerp 导入“_”。像这样:
from openerp.tools.translate import _
不引用布尔(非布尔)字段。错误是从 _setup_related[=16 生成的(来自 tracebak:File "C:\Program Files (x86)\Odoo 8.0-20170914\server.\openerp\fields.py",第 514 行,在 _setup_related 中) =]方法,根据源码:设置相关字段的属性。因此,我建议您检查任何具有相关属性的字段。 并检查 adnl_n_pages_one_color 字段是否存在于 book_block 模型中。