我有这个方法:
@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,
'credit': 0,
'account_id': record.transporter.transp_transit,
'date': date,
'partner_id': record.transporter,
}),
]
journal_id = False
if record.transporter.property_account_payable:
journals = self.env['account.journal'].search([
('default_debit_account_id', '=', record.transporter.property_account_payable.id)
])
if journals:
journal_id = journals[0].id
acc_move.create({
'journal_id': journal_id,
'date':date,
'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
每当我尝试creaet(或更改为awaitingraw
)状态时,它就会抛出这个:
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 4245, in _create
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
DataError: la sintaxis de entrada no es válida para tipo date: «<type 'datetime.date'>»
LINE 1: ...account_move_id_seq'), '/', 1, NULL, 'draft', 13, '<type ''d...
^
因此,在两种情况下,违规行都是'date': date,
,所以,我该如何克服这个问题呢?我应该将'date'
放在''
之间吗?
我不确定,或者可能是实际约会的三角洲,我见过这样的'date': fields.Date.today(),
,但我不确定......
有什么想法吗?
答案 0 :(得分:1)
您正在尝试使用整数来设置日期字段。您可以使用前面提到的fields.Date.today()
,也可以使用strptime
将整数转换为日期。
datetime.datetime.strptime('2017-12-11', '%Y-%m-%d')