Skip to Content
Menu
This question has been flagged
1 Reply
5883 Views

I'm just adding some related fields to my model, some other fields work, but for this model they just won't, these are my models:

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")

The book_block field is okay, the issue comes with n_pages_one_color and adnl_n_pages_one_color fields, it throws me:

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'

I don't get it, it should work, I don't see anything wrong on it, even book_block Many2one field is Okay, so, what's the deal?

Any ideas?

Avatar
Discard

are you sure your field book_block getting a valid value, related fields are now trying to get value form bool, thats why.

Related Posts Replies Views Activity
3
Sep 21
8241
4
Jan 20
2213
0
Nov 18
3406
0
Apr 17
2730
3
Oct 22
4115