# -*- coding: utf-8 -*- # Copyright 2024-2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) from odoo import models class LoanerEmailMixin(models.AbstractModel): _name = 'fusion.loaner.email.mixin' _description = 'Loaner Email Builder Mixin' _EMAIL_COLORS = { 'info': '#2B6CB0', 'success': '#38a169', 'attention': '#d69e2e', 'urgent': '#c53030', } def _email_build( self, title, summary, sections=None, note=None, note_color=None, email_type='info', attachments_note=None, button_url=None, button_text='View Details', sender_name=None, extra_html='', ): accent = self._EMAIL_COLORS.get(email_type, self._EMAIL_COLORS['info']) company = self._get_company_info() parts = [] parts.append( f'
{company["name"]}
' ) parts.append( f'{summary}
' ) if sections: for heading, rows in sections: parts.append(self._email_section(heading, rows)) if note: nc = note_color or accent parts.append(self._email_note(note, nc)) if extra_html: parts.append(extra_html) if attachments_note: parts.append(self._email_attachment_note(attachments_note)) if button_url: parts.append(self._email_button(button_url, button_text, accent)) signer = sender_name or (self.env.user.name if self.env.user else '') parts.append( f''
f'Best regards,
'
f'{signer}
'
f'{company["name"]}
'
f'{footer_text}
'
f'This is an automated notification from the Loaner Management System.
| {heading} | |
| {label} | ' f'{value} | ' f'
{text}
' f'' f'{text}
' ) def _email_attachment_note(self, description): return ( f'' f'Attached: {description}
' f'