gpt4 book ai didi

python - key 错误 : 8 - Odoo v8

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:20 24 4
gpt4 key购买 nike

在此方法上:

@api.multi
@api.onchange('order_picking')
@api.constrains('order_picking', 'order_picking.isbn')
def check_quantity(self):
location = self.printer_book_block.property_stock_supplier.id
for rec in self:
if rec.order_picking:
for line in rec.order_picking:
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',})

它给了我这个:

2017-12-14 01:50:15,732 5080 WARNING hasta_cuandooo_def openerp.models: method bsi.print.order.check_quantity: @constrains parameter 'order_picking.isbn' is not a field name
2017-12-14 01:50:16,075 5080 ERROR hasta_cuandooo_def openerp.http:
Exception during JSON request handling.
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\api.py", line 399, in old_api
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\bsi\models\models.py", line 1472, in check_quantity
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\models.py", line 3789, in write
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\api.py", line 592, in new_api
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 4048, in _write
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\models.py", line 5773, in recompute
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 5773, in <dictcomp>
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 5654, in __getitem__
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\fields.py", line 841, in __get__
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 6056, in __getitem__
KeyError: 8

有问题的行是:

rec.write({'state': 'awaitingraw'})

此方法检查产品行(isbn)以查看是否有足够的数量,如果没有,则继续 awaitingraw ,如果足够,则转到work_in_progress 。但这很奇怪,错误是在我添加此方法之后出现的(在 check_quantity 之前):

@api.multi
@api.depends('order_picking', 'order_picking.isbn', 'contract_worksheet', 'state')
def accounting_scenarios(self):
for record in self:
if not len(record.transporter):
raise Warning('Please Enter Transporter !')
elif not len(record.transporter.transp_transit):
raise Warning('Please assign transit account to the transporter !')
if record.state in ('awaitingraw'):
record.temp = record.contract_worksheet.total_alles - record.contract_worksheet.total_totals
acc_move = self.env['account.move']
move_lines = [
(0, 0, {
'name': 'name',
'debit': record.temp or 0.0,
'credit': 0,
'account_id': record.transporter.transp_transit.id,
'date': fields.Date.today(), #date,
'partner_id': record.transporter.id, # partner if there is one
#'currency_id': currency_id or (account.currency_id.id or False),
}),
(0, 0, {
'name': 'name',
'debit': 0,
'credit': record.contract_worksheet.total_alles or 0.0,
'account_id': record.transporter.transp_transit.id,
#'analytic_account_id': context.get('analytic_id', False),
'date': fields.Date.today(), #date,
'partner_id': record.transporter.id,
#'currency_id': currency_id or (account.currency_id.id or False),
})
]

journal_id = False
if record.transporter.transp_transit:
journals = self.env['account.journal'].search([
('default_debit_account_id', '=', record.transporter.transp_transit.id)
])
if journals:
journal_id = journals[0].id
acc_move.create({
#'period_id': period_id, #Fiscal period
'journal_id': journal_id,
'date': fields.Date.today(),
'state': 'draft',
'line_id': move_lines,
})
#return move.id
elif record.state in ('work_in_progress'):
record.temp2 = record.contract_worksheet.total_totals
elif record.state in ('delivered'):
record.transporter.transp_transit.debit = record.contract_worksheet.total_alles

这似乎现在有效,所以,有什么想法吗?

编辑

此外,当我尝试编辑记录并编辑字段 printer_book_block 时,保存时会抛出:

         ValidateError

Error while validating constraint

8

这是字段:

printer_book_block = fields.Many2one('res.partner', string="Printer Book Block")

编辑2

问题似乎出在 printer_book_block 之间。这是 Many2oneres.partner ,以及我正在处理的类 ID,每次创建新记录时它存储的序列 ID,我看到了这个 8作为文档的 ID,无论我尝试编辑什么,都是如此。

错误发生了,它只是明显地改变了数字,这取决于我正在编辑哪个,非常令人费解......

最佳答案

首先,您需要将此行移动到 for 循环内,并从 rec 而不是 self 获取位置。

     for rec in self:
location = rec.printer_book_block.property_stock_supplier.id

现在我在这里没有看到错误,因此您评论位置并计算所有位置中的可用数量,但此错误仍然会出现

关于python - key 错误 : 8 - Odoo v8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47804583/

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