Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
588 มุมมอง

Hello,

when I create an invoice manually in Odoo interface, the *_ubl_de.xml file is created next to the invoice.

However, when the invoice is created from my custom code where the sale is added, it is not created, only the pdf invoice is created.

How do I handle this in the code so that it is also created? 

In this exampe i use .message_post() method adds only one attachment (pdf) to the message

attachment_ids = request.env['ir.attachment'].sudo().search([

('res_model', 'in', ['account.move', 'mail.compose.message']),

('res_id', '=', invoice.id)

])

_logger.info('/////ATTACHMENT BY INVOICE//////')

_logger.info(attachment_ids)

for attachment in attachment_ids:

attachment.res_model = 'mail.message'

ids_for_email.append(attachment.id)

_logger.info('/////IDS FOR EMAIL//////')

_logger.info(ids_for_email)

invoice.with_context(mail_post_autofollow=True,

lang=partner.lang or request.env.user.lang).message_post(

partner_ids=[partner.id],

body=email_values.get('body_html'),

subject=subject,

subtype_id=request.env.ref('mail.mt_note').id,

model_description=subject,

email_layout_xmlid='mail.mail_notification_light',

attachment_ids=ids_for_email

)


ir_attachment table for this res_id

  id   |       name        |      res_model       | res_id

-------+-------------------+----------------------+--------

37555 | RE3610.pdf        | account.move         |  21446

37554 | RE3610_ubl_de.xml | mail.compose.message |  21446


Logs from this code
/////ATTACHMENT BY INVOICE//////
ir.attachment(37555, 37554)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ค. 23
2135
2
ก.ย. 24
11186
0
ต.ค. 22
2389
0
มี.ค. 22
2
1
พ.ย. 19
5633