# -*- coding: utf-8 -*- # Copyright 2024-2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) """ MOD Resubmit Wizard — lets the office revise an order that MOD has denied, and kick it back into the workflow at `processing_drawings` so the specialist can update drawings/proposal/quotation before it is re-submitted to MOD. """ from odoo import models, fields, api, _ from odoo.exceptions import UserError from markupsafe import Markup class ModResubmitWizard(models.TransientModel): _name = 'fusion_claims.mod.resubmit.wizard' _description = 'MOD - Resubmit After Denial' sale_order_id = fields.Many2one('sale.order', required=True, readonly=True) revision_notes = fields.Text( string='Revision Notes', required=True, help='Describe what is being revised for the resubmission ' '(scope changes, updated pricing, additional documentation, etc).', ) clear_old_documents = fields.Boolean( string='Clear old drawings / proposal / quotation', default=False, help='Tick this if the new submission needs entirely new drawings and ' 'proposal. The previous documents are preserved in chatter before ' 'being cleared.', ) @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 return res def action_confirm(self): self.ensure_one() order = self.sale_order_id if order.x_fc_mod_status != 'funding_denied': raise UserError(_("Only denied orders can be resubmitted via this wizard.")) if self.clear_old_documents: # Preserve the old docs in chatter before clearing them. preserved = [] if order.x_fc_mod_drawing: preserved.append('Drawing') if order.x_fc_mod_proposal_doc: preserved.append('Proposal') if preserved: order.message_post( body=Markup( f'' ), message_type='notification', subtype_xmlid='mail.mt_note', ) order.with_context(skip_status_emails=True).write({ 'x_fc_mod_drawing': False, 'x_fc_mod_drawing_filename': False, 'x_fc_mod_proposal_doc': False, 'x_fc_mod_proposal_doc_filename': False, }) order.with_context(skip_status_emails=True).write({ 'x_fc_mod_status': 'processing_drawings', }) body = ( f'' ) order.message_post( body=Markup(body), message_type='notification', subtype_xmlid='mail.mt_note', ) return {'type': 'ir.actions.act_window_close'}