我有此嚮導按鈕,從而節省字段上的表記錄:ValueError異常混合蘋果和桔子:my.model()<假 - Odoo V8
@api.multi
def save_data(self, vals):
vals = {
self.name : 'name',
self.date_production : 'date_production',
self.type_prod : 'type_prod',
self.product_id : 'product_id',
self.qty_available : 'qty_available',
self.print_order2 : 'print_order2',
self.name_block : 'name_block',
}
self.env['bsi.production.order'].create(vals)
這是一步步向導,這些是在我的模型中的信息字段:
class bsi_production_order(models.Model):
_name = 'bsi.production.order'
_inherit = ['mail.thread','text.paper','book.binding', 'book.block','book.edge','book.edition','book.size','cut.off','end.paper','job.rate','paper.master','printing.code', 'mrp.worksheet.contract', 'work.order.isbn.code', 'product.template']
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('bsi.production.order') or '/'
return super(bsi_production_order, self).create(vals)
name = fields.Char('Reference', required=True, index=True, copy=False, readonly='True', default='New')
date_production = fields.Date(string="Production Date")
type_prod = fields.Selection([
('budgeted','Budgeted'),
('nonbudgeted','Non Budgeted'),
('direct','Direct Order'),
], string='Type of Order', index=True,
track_visibility='onchange', copy=False,
help=" ")
product_id = fields.Many2one('product.template', string="Product")
qty_available = fields.Float(string="Qty Available", related="product_id.qty_available")
production_qty = fields.Float(string="Qty to produce")
print_order2 = fields.Many2one('bsi.print.order', string="Print Order")
book_block = fields.Many2one('book.block',)
name_block = fields.Selection(string="Code", related="book_block.name_block", store=True)
當我嘗試從嚮導保存記錄,它說:
ValueError
Mixing apples and oranges: bsi.print.order() < False
任何想法S'
編輯
這是肯定的東西有關Many2one
和/或One2many
場,我有這樣的另一個錯誤與其他領域,這是一個Many2one
類型的字段。
還有一些好奇的事情可能與它有關,而且事實上,當我以傳統方式保存bsi.production.order
而不是嚮導時,會顯示Many2one related
字段,但是當我保存新記錄,他們只是空了,就像它不能保存它們,我已經添加了store=True
標誌給他們,但仍然是相同的行爲。
第二個編輯
完整的堆棧跟蹤:
2017-08-26 22:42:46,786 1688 ERROR bsi_def openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 948, in call_button
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 399, in old_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_worksheet_contract\models\models.py", line 780, in save_data
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_worksheet_contract\models\models.py", line 476, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_worksheet_contract\models\models.py", line 15, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 508, in new_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\product\product.py", line 742, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 372, in old_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_work_order_isbn\models\models.py", line 28, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 508, in new_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mail\mail_thread.py", line 381, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 372, in old_api
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\models.py", line 4101, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\models.py", line 5608, in __lt__
except_orm: ('ValueError', 'Mixing apples and oranges: bsi.print.order() < False')
完整的堆棧跟蹤,請 –
嗨,添加了完整的堆棧跟蹤,看到我的編輯,謝謝您 – NeoVe
的問題出現在'Many2one'字段中,我認爲這與'self.env'調用我的模型有關,它實際上在我的表中創建了一個新記錄,出於某種原因與Many2one字段存在衝突 – NeoVe