تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
575 أدوات العرض

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)

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مايو 23
2134
2
سبتمبر 24
11174
0
أكتوبر 22
2384
0
مارس 22
2
1
نوفمبر 19
5629