from odoo import models, fields, api

class ReasonWizard(models.TransientModel):
    _name = 'hold_cancel_reason_wizard'
    _description = 'Reason Wizard'

    indent_status = fields.Selection([('cancel', 'Cancel'), ('hold', 'Hold'), ('open', 'Open')], string='Indent Status', default="cancel")
    reason = fields.Text(string='Remarks', required=True)
    approval_image = fields.Image(string='Authorised Signatory',readonly=True)
    approval_name = fields.Many2one('res.users', string='Authorised By')

    def approved_by_sign_btn(self):
        model = self.env['sos_fg_plan'].browse(self._context.get('default_model_id'))
        model.hold_cancel_reason = self.reason
        model.hold_cancel_by = self.env.user
        model.indent_status = self.indent_status
        sequence_util = self.env['sos_common_scripts']
        sequence_util.action_assign_signature(
        self, 
        'approval_image',
        'approval_name'
        )
