Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
564 Ansichten

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)

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Mai 23
2133
2
Sept. 24
11172
0
Okt. 22
2383
0
März 22
2
1
Nov. 19
5625