# -*- coding: utf-8 -*- # Copyright 2024-2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) """ MOD Submission Confirmed Wizard — office confirms that a client or authorizer has submitted the application to MOD, captures the actual submission date, and advances the order from handoff_to_client to awaiting_funding. """ from odoo import models, fields, api, _ from odoo.exceptions import UserError from markupsafe import Markup class ModSubmissionConfirmedWizard(models.TransientModel): _name = 'fusion_claims.mod.submission.confirmed.wizard' _description = 'MOD - Confirm Application Submitted' sale_order_id = fields.Many2one('sale.order', required=True, readonly=True) submitted_by_label = fields.Char(string='Submitted By', readonly=True) application_submitted_date = fields.Date( string='Actual Submission Date', required=True, default=fields.Date.context_today, help='Date the client or authorizer told us they actually submitted ' 'the application to March of Dimes.', ) confirmation_source = fields.Selection( selection=[ ('phone_call', 'Phone call with client'), ('email', 'Email from client'), ('client_portal', 'Client used our portal'), ('authorizer', 'Confirmed by authorizer (OT)'), ('other', 'Other'), ], string='How was this confirmed?', required=True, default='phone_call', ) confirmation_notes = fields.Text( string='Notes from confirmation', help='What did the client say? Confirmation number from MOD if given?', ) @api.model def default_get(self, fields_list): res = super().default_get(fields_list) if self.env.context.get('active_id'): order = self.env['sale.order'].browse(self.env.context['active_id']) res['sale_order_id'] = order.id path_labels = { 'internal': 'We (internal)', 'client': 'Client', 'authorizer': 'Authorizer (OT)', } res['submitted_by_label'] = path_labels.get( order.x_fc_mod_submitted_by, 'Unknown') return res def action_confirm(self): self.ensure_one() order = self.sale_order_id if order.x_fc_mod_status != 'handoff_to_client': raise UserError( _("This wizard is only for orders that have been handed off " "to the client or authorizer for submission. Current status: %s") % order.x_fc_mod_status ) order.write({ 'x_fc_mod_status': 'awaiting_funding', 'x_fc_mod_application_submitted_date': self.application_submitted_date, }) source_labels = dict(self._fields['confirmation_source'].selection) body = ( f'' order.message_post( body=Markup(body), message_type='notification', subtype_xmlid='mail.mt_note', ) return {'type': 'ir.actions.act_window_close'}