2017-12-11 11 views
1

は、私はこの方法があります:構文エラー「日付」フィールド - OdooのV8

:私はcreaet(または awaitingrawに変更)しようとするたびに

@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 

を状態、それがこの私をスローします

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(),ような何かを見てきましたが、私はわからないんだけど、私はわからない、または多分デルタは、実際の日付を取るために?

答えて

1

整数を使用して日付フィールドを設定しようとしています。上記のようにfields.Date.today()を使用するか、strptimeを使用して日付に整数を変換することができます。

datetime.datetime.strptime('2017-12-11', '%Y-%m-%d') 
+1

ありがとうございます。実際にfields.Date.today()works! – NeoVe

関連する問題