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

I have the following code called from an ir.cron entry.  The code works perfectly when 'Run Manually' but the record is not updated when run automatically.  Any ideas why ?  Does it have to be run under sudo ?

def reset_date(self):
_logger.debug("Finding records with ecd < %s", fields.Date.context_today(self))
records = self.env['module.name'].search([('ecd', '
for record in records:
if record.state == 'prelodged':
_logger.debug("Checking dr with name %s for ecd < %s", record.name, \fields.datetime.now())
record.write({'ecd': date.today()})

아바타
취소

Did you check if method called and the _logger.debug shows in log when run automatically

작성자 베스트 답변

Yes, you do have to use sudo() if you're writing to a record within a cron job.  The line should be:

record.sudo().write({'ecd': date.today()})
아바타
취소
관련 게시물 답글 화면 활동
1
10월 23
2451
1
3월 20
3598
1
11월 24
5663
0
3월 24
2203
0
1월 24
77