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

Hi everyone!

I'm having a problem with several of our cron when they run on a kubernetes environment. Most of the time, the cron works fine and produces the expected results, but from time to time, i have this kind of errors:


ValueError: <class 'AttributeError'>: "'sale.order' object has no attribute 'cron_generate_invoice'" while evaluating 'model.cron_generate_invoice()'

I know that this issue appear when the method does not exist on the model, or it might also appear if the dependency to the module in which it is defined is not correctly set. But in my case, the cron and the method are defined in the same module, and the cron works most of the time, so i don't think its a code related issue.


Has anyone already faced this kind of errors? It really is a problem for us, since multiple crons are used to generated invoices, or things that will need to be invoiced later. So of course, the invoices are wrong or were simply never created :/


Thanks a lot!

아바타
취소
베스트 답변

are you working on V13 ?

아바타
취소
작성자

yes :)

did you add @api.model to cron_generate_invoice ?

작성자

I'll try that tomorrow and hope for the best, indeed i didnt decorate my method with @api.model. But if that causes the problem, what would be the technical explanation? Because the cron works most of the time (i'd say 8 times out of 10) and i don't think that decorator could provoke or fix that?

Also, the cron never fails when i launch it manually with the button in the backend. And never failed on our old infrastructure: it began failing when we migrated to kubernetes

My answer is not related to kubernetes. I would say the cron should work whatever is the os/container system.

I had similar issue and resolved by adding api.model because in V13, functions have api.multi by default. As far as I know, cron should be api.model because we don't have any record (self empty).

Hope it works for you.

Good luck