This commit is contained in:
2026-02-03 13:58:00 +01:00
parent 43312ba412
commit 403db5133e

View File

@@ -710,14 +710,21 @@ class ShipmentIn(metaclass=PoolMeta):
for sh in shipments:
sh.result = "Email not sent"
attachment = None
attachment = []
if sh.add_bl:
attachments = Attachment.search([
('resource', '=', 'stock.shipment.in,' + str(sh.id)),
])
if attachments:
attachment = attachments[0]
content_b64 = base64.b64encode(attachments[0].data).decode('ascii')
attachment = [
{
"filename": attachments[0].name,
"content": content_b64,
"content_type": attachments[0].mimetype or "application/pdf"
}
]
if sh.controller:
Contact = Pool().get('party.contact_mechanism')
contact = Contact.search(['party','=',sh.controller.id])
@@ -726,13 +733,7 @@ class ShipmentIn(metaclass=PoolMeta):
"to": [contact[0].value],
"subject": "Request for control",
"body": sh.html_to_text(sh.instructions),
"attachments": [
{
"filename": attachment.name,
"content": attachment.data,
"content_type": "application/pdf"
}
],
"attachments": attachment,
"meta": {
"shipment": sh.bl_number,
"controller": sh.controller.id