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

Hello all,

here's the problem I can't solve.

I'm building an API integration module that will allow Odoo 16 (enterprise) to handle invoices triggered in an external web shop. So I'm trying to programmatically create an invoice, that's fully confirmed, sent and printed, and its PDF would be available from external website.

This is how I create it:

 
- create an invoice with f.e.: 

invoice = request.env['account.move'].create({...})

 - create lines with

request.env['account.move.line'].create({...})

- call

invoice._post()

to make it confirmed. 


Then invoice number is returned to the external shop.

This is how I send PDF:

stream = pdf.to_pdf_stream(invoice.message_main_attachment_id)
[...]
return stream.getvalue()

The problem is - how to programmatically make message_main_attachment_id available for the invoice? When doing it via WebUI user has to click "Send & Print", configure stuff in dialog box, then confirm - which creates via RPC account.invoice.send object and then generates a PDF available as attachment. I would like to know how this can be done in code, without enduser's actions.


Thanks for any suggestions.


아바타
취소
관련 게시물 답글 화면 활동
2
12월 24
6491
2
6월 24
11596
1
4월 24
2590
1
6월 24
2764
2
7월 23
2283