编程错误:无法调整类型' account.account' - Odoo v8

时间:2017-12-14 00:21:01

标签: python openerp odoo-8

我有这个方法:

@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'): #('cancel', 'done')
            record.temp = record.contract_worksheet.total_alles - record.contract_worksheet.total_totals
            acc_move = self.env['account.move'] 
            move_lines = [
                (0, 0, {
                    'name': 'name', # a label so accountant can understand where this line come from
                    'debit': record.temp or 0.0, # amount of debit
                    'credit': 0, # amount of credit
                    'account_id': record.transporter.transp_transit, 
                    'date': date,
                    'partner_id': record.transporter, 
                    #'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, 
                    })
        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

我已经意识到debitcredit字段的问题,问题是该期刊没有帐户(transp_transit)作为默认借记或赠送金额帐户。

无论如何,现在它似乎正在尝试account.move,但它让我这样:

2017-12-14 00:44:34,438 2736 INFO hasta_cuandooo_def werkzeug: 127.0.0.1 - - 
[14/Dec/2017 00:44:34] "POST /web/dataset/call_button HTTP/1.1" 200 -
2017-12-14 00:44:38,177 2736 ERROR hasta_cuandooo_def openerp.sql_db: 
Programming error: can't adapt type 'account.account', in query  SELECT 
"account_account"."id","account_account"."active" FROM "account_account"
                    WHERE "account_account".id IN %s  ORDER BY "account_account"."parent_left"  

2017-12-14 00:44:38,177 2736 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\addons\bsi\models\models.py", line 1400, 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 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 835, in __get__
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\fields.py", line 913, in determine_value
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\fields.py", line 893, in compute_value
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\fields.py", line 885, in _compute_value
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 1390, in accounting_scenarios
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 508, in new_api
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\account\account.py", line 1388, in create
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 4101, in create
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 508, in new_api
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 4292, in _create
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\osv\fields.py", line 799, in set
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\account\account_move_line.py", line 1276, in create
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\models.py", line 3148, in read
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 3183, in read
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 3312, in _read_from_database
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\sql_db.py", line 171, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\sql_db.py", line 247, in execute
File "psycopg2\extensions.pyc", line 129, in getquoted
ProgrammingError: can't adapt type 'account.account'

有什么想法吗?

修改

我班上有这个字段:

transporter = fields.Many2one('res.partner', string="Transporter", domain="[('type_of_supplier','=','transporter')]")

res.partner(转运人)上:

transp_transit = fields.Many2one('account.account', string='Transporter Transit Account')

1 个答案:

答案 0 :(得分:1)

当你传递值来创建或写入时,请确保你没有为many2one字段传递对象传递id

          'partner_id': record.transporter.id