changes
This commit is contained in:
@@ -623,6 +623,7 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if not template:
|
||||
_logger.error("Renewal confirmation template not found for %s", self.name)
|
||||
return
|
||||
|
||||
attachment_ids = []
|
||||
@@ -635,14 +636,18 @@ class SaleOrder(models.Model):
|
||||
invoice, 'Renewal',
|
||||
)
|
||||
|
||||
template.with_context(
|
||||
payment_ok=payment_ok,
|
||||
renewal_log=renewal_log,
|
||||
).send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
try:
|
||||
template.with_context(
|
||||
payment_ok=payment_ok,
|
||||
renewal_log=renewal_log,
|
||||
).send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
_logger.warning("Renewal confirmation email sent for %s", self.name)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to send renewal confirmation email for %s: %s", self.name, e)
|
||||
|
||||
def _send_payment_receipt_email(self, invoice, transaction):
|
||||
"""Send payment receipt email after successful collection."""
|
||||
@@ -912,7 +917,13 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if template:
|
||||
template.send_mail(self.id, force_send=True)
|
||||
try:
|
||||
template.send_mail(self.id, force_send=True)
|
||||
_logger.warning("Rental agreement email sent for %s", self.name)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to send agreement email for %s: %s", self.name, e)
|
||||
else:
|
||||
_logger.error("Agreement email template not found for %s", self.name)
|
||||
self.message_post(body=_("Rental agreement sent to customer for signing."))
|
||||
|
||||
def action_send_card_reauthorization(self):
|
||||
@@ -1308,6 +1319,7 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if not template:
|
||||
_logger.error("Deposit refund initiated template not found for %s", self.name)
|
||||
return
|
||||
|
||||
attachment_ids = []
|
||||
@@ -1317,11 +1329,15 @@ class SaleOrder(models.Model):
|
||||
credit_note, 'Deposit Credit Note',
|
||||
)
|
||||
|
||||
template.send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
try:
|
||||
template.send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
_logger.warning("Deposit refund initiated email sent for %s", self.name)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to send deposit refund initiated email for %s: %s", self.name, e)
|
||||
|
||||
def _send_deposit_refund_email(self):
|
||||
"""Send the security deposit refund completion email with credit note and receipt."""
|
||||
@@ -1331,6 +1347,7 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if not template:
|
||||
_logger.error("Deposit refund template not found for %s", self.name)
|
||||
return
|
||||
|
||||
attachment_ids = []
|
||||
@@ -1342,11 +1359,15 @@ class SaleOrder(models.Model):
|
||||
receipt_ids = self._find_poynt_receipt_attachments(credit_note)
|
||||
attachment_ids.extend(receipt_ids)
|
||||
|
||||
template.send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
try:
|
||||
template.send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
_logger.warning("Deposit refund email sent for %s", self.name)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to send deposit refund email for %s: %s", self.name, e)
|
||||
|
||||
def _send_invoice_with_receipt(self, invoice, invoice_type=''):
|
||||
"""Send invoice email with the invoice PDF and payment receipt attached.
|
||||
@@ -1361,6 +1382,7 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if not template:
|
||||
_logger.error("Invoice receipt email template not found for %s", self.name)
|
||||
return
|
||||
|
||||
type_label = {
|
||||
@@ -1374,14 +1396,24 @@ class SaleOrder(models.Model):
|
||||
receipt_ids = self._find_poynt_receipt_attachments(invoice)
|
||||
attachment_ids.extend(receipt_ids)
|
||||
|
||||
template.with_context(
|
||||
rental_invoice=invoice,
|
||||
rental_invoice_type=invoice_type,
|
||||
).send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
try:
|
||||
template.with_context(
|
||||
rental_invoice=invoice,
|
||||
rental_invoice_type=invoice_type,
|
||||
).send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
_logger.warning(
|
||||
"Invoice receipt email sent for %s (%s) with %d attachments",
|
||||
self.name, type_label, len(attachment_ids),
|
||||
)
|
||||
except Exception as e:
|
||||
_logger.error(
|
||||
"Failed to send invoice receipt email for %s (%s): %s",
|
||||
self.name, type_label, e,
|
||||
)
|
||||
|
||||
# =================================================================
|
||||
# Email Attachment Helpers
|
||||
@@ -1605,11 +1637,17 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if template:
|
||||
template.send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': [attachment.id]},
|
||||
)
|
||||
try:
|
||||
template.send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': [attachment.id]},
|
||||
)
|
||||
_logger.warning("Signed agreement email sent for %s", self.name)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to send signed agreement email for %s: %s", self.name, e)
|
||||
else:
|
||||
_logger.error("Signed agreement email template not found for %s", self.name)
|
||||
|
||||
def action_preview_rental_agreement(self):
|
||||
"""Open the rental agreement PDF in a preview dialog."""
|
||||
@@ -1702,14 +1740,19 @@ class SaleOrder(models.Model):
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
if not template:
|
||||
_logger.error("Thank you email template not found for %s", self.name)
|
||||
return
|
||||
|
||||
attachment_ids = self._generate_agreement_attachment_ids()
|
||||
|
||||
template.with_context(
|
||||
google_review_url=self._get_google_review_url(),
|
||||
).send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
try:
|
||||
template.with_context(
|
||||
google_review_url=self._get_google_review_url(),
|
||||
).send_mail(
|
||||
self.id,
|
||||
force_send=True,
|
||||
email_values={'attachment_ids': attachment_ids} if attachment_ids else {},
|
||||
)
|
||||
_logger.warning("Thank you email sent for %s", self.name)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to send thank you email for %s: %s", self.name, e)
|
||||
|
||||
Reference in New Issue
Block a user