콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
23928 화면

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
13277
2
7월 25
4802
3
6월 25
1031
2
12월 24
7897
2
11월 24
28701