コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
23907 ビュー

In order to change the state of a record from draft to confirm depending on its own given date... in model after importing datetime, date:

date = fields.Date('Date', default=lambda * a: time.strftime('%Y-%m-%d'))
state = fields.Selection([('draft', 'Draft'), ('confirm', 'Confirm')], readonly=True, default='draft')

method:

@api.multi
def confirm_record(self):
current_date = str(datetime.now().date())
self.search(['date', '==', current_date]).write({'state': 'confirm'}):
return True
     

this metod is call by an automated action (ir.cron) and log file says:

ValueError: Invalid leaf date.

Odoo 10

アバター
破棄

Is it necesary to format current_date string?

最善の回答

Hi 

The syntax of search method is wrong.

change this line

self.search([('date', '=', current_date)]).write({'state': 'confirm'})
アバター
破棄
関連投稿 返信 ビュー 活動
1
9月 19
13267
2
7月 25
4778
3
6月 25
1022
2
12月 24
7887
2
11月 24
28681