将布尔值从模型更改为 True - Odoo v8

Change boolean to True from model to lines - Odoo v8

我有这个方法:

@api.multi
@api.onchange('order_lines', 'order_lines.is_book_block', '')
@api.constrains('order_lines', 'order_lines.isbn')
def check_quantity(self):
    location = self.printer_book_block.property_stock_supplier.id
    for rec in self:
        if rec.order_lines:
            for line in rec.order_lines:
                if line.qty > line.isbn.with_context({ 'location': location, }).qty_available >= 0:#line.isbn.qty_available in location:
                    rec.write({'state': 'awaitingraw'})
                else:
                    rec.write({'state': 'work_in_progress',},{'is_book_block': True})

它的作用是在指定位置查找 order_lines 的产品数量,这样做恰到好处,而且,除了将表单状态写入 work_in_progress 之外,而且,它应该将 order_lines 字段 is_book_block 更改为 True。 (如果指定位置有足够的产品数量)

数量部分没问题,但由于我添加了布尔部分,

它给我带来了这个:

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 944, in call_kw
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\api.py", line 399, in old_api
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 5989, in onchange
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 5832, in _onchange_eval
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\bsi\models\models.py", line 1360, in check_quantity
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 266, in wrapper
TypeError: write() takes exactly 2 arguments (3 given)

有什么想法吗?

我认为这是因为 onchange 装饰器,但不应该是这样吗?我的意思是,该产品并不总是可用的。

只写接受字典一个

   rec.write({
        'state': 'work_in_progress',
         'is_book_block': True,
         # you can put as many field as you want but inside this dicionary
  })