feat(fusion_portal): wire ADP/express into visit + portal entry tile + email consolidation
- express save captures visit_id; when visit-linked, action=submit saves the ADP assessment as a draft (signature + Page 11 PDF still captured) and returns to the visit instead of completing into a standalone SO, so the visit groups the ADP devices into one funding-routed order. Non-visit express flow unchanged. - portal dashboard: featured 'Start a Visit' tile (sales reps) -> /my/visit/new. - fix duplicate-authorizer email: _send_completion_notifications no longer re-emails the authorizer (already emailed with the full report by _send_assessment_completed_email); it now only notifies the client. - visit grouped accessibility SOs now send one office completion email per SO. Bump 19.0.2.10.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1486,20 +1486,18 @@ class FusionAssessment(models.Model):
|
||||
})
|
||||
|
||||
def _send_completion_notifications(self):
|
||||
"""Send email notifications when assessment is completed"""
|
||||
"""Notify the CLIENT that the assessment is complete.
|
||||
|
||||
The authorizer, sales rep and office are already emailed (with the full
|
||||
assessment report) by ``_send_assessment_completed_email`` inside
|
||||
``_create_draft_sale_order``. This method used to ALSO send the
|
||||
authorizer a second, template-only email — that duplicate is removed;
|
||||
here we only notify the client.
|
||||
"""
|
||||
self.ensure_one()
|
||||
|
||||
# Send to authorizer
|
||||
if self.authorizer_id and self.authorizer_id.email:
|
||||
try:
|
||||
template = self.env.ref('fusion_portal.mail_template_assessment_complete_authorizer', raise_if_not_found=False)
|
||||
if template:
|
||||
template.send_mail(self.id, force_send=True)
|
||||
_logger.info(f"Sent assessment completion email to authorizer {self.authorizer_id.email}")
|
||||
except Exception as e:
|
||||
_logger.error(f"Failed to send authorizer notification: {e}")
|
||||
|
||||
# Send to client
|
||||
|
||||
# Send to client (authorizer/rep/office already emailed by
|
||||
# _send_assessment_completed_email in _create_draft_sale_order)
|
||||
if self.client_email:
|
||||
try:
|
||||
template = self.env.ref('fusion_portal.mail_template_assessment_complete_client', raise_if_not_found=False)
|
||||
|
||||
@@ -184,6 +184,16 @@ class FusionAssessmentVisit(models.Model):
|
||||
subtype_xmlid='mail.mt_note',
|
||||
)
|
||||
assessment.write({'state': 'completed'})
|
||||
# One completion notification per SO (not per assessment) — mirrors the
|
||||
# standalone accessibility completion's office email.
|
||||
if accessibility_assessments:
|
||||
try:
|
||||
accessibility_assessments[0]._send_completion_email(sale_order)
|
||||
except Exception as e:
|
||||
_logger.warning(
|
||||
"Visit %s: completion email failed for %s: %s",
|
||||
self.name, sale_order.name, e,
|
||||
)
|
||||
_logger.info(
|
||||
"Visit %s created %s sale order %s grouping %d accessibility assessment(s)",
|
||||
self.name, sale_type, sale_order.name, len(accessibility_assessments),
|
||||
|
||||
Reference in New Issue
Block a user