
from odoo import _, api, models


class DocumentCancelWizard(models.TransientModel):
    _name = 'l10n_br_fiscal.document.cancel.wizard'
    _description = 'Fiscal Document Cancel Wizard'
    _inherit = 'l10n_br_fiscal.base.wizard.mixin'

    @api.multi
    def doit(self):
        for wiz in self:
            if wiz.document_id:
                message = _("Cancellation: {}").format(wiz.justification)
                wiz.document_id.with_context(message=message)._document_cancel()
        return {'type': 'ir.actions.act_window_close'}


from odoo import api, models


class DocumentCancelWizard(models.TransientModel):
    _name = 'l10n_br_fiscal.document.cancel.wizard'
    _description = 'Fiscal Document Cancel Wizard'
    _inherit = 'l10n_br_fiscal.base.wizard.mixin'

    @api.multi
    def doit(self):
        for wizard in self:
            if wizard.document_id:
                wizard.document_id._document_cancel(wizard.justification)
        self._close()

Update Fiscal document cancel wizard
[FIX] Update Fiscal document cancel wizard

  
- from odoo import _, api, models
+ from odoo import api, models
  
  
  class DocumentCancelWizard(models.TransientModel):
      _name = 'l10n_br_fiscal.document.cancel.wizard'
      _description = 'Fiscal Document Cancel Wizard'
      _inherit = 'l10n_br_fiscal.base.wizard.mixin'
  
      @api.multi
      def doit(self):
-         for wiz in self:
+         for wizard in self:
-             if wiz.document_id:
+             if wizard.document_id:
+                 wizard.document_id._document_cancel(wizard.justification)
+         self._close()
-                 message = _("Cancellation: {}").format(wiz.justification)
-                 wiz.document_id.with_context(message=message)._document_cancel()
-         return {'type': 'ir.actions.act_window_close'}
  
Update Fiscal document cancel wizard
## Code Before:

from odoo import _, api, models


class DocumentCancelWizard(models.TransientModel):
    _name = 'l10n_br_fiscal.document.cancel.wizard'
    _description = 'Fiscal Document Cancel Wizard'
    _inherit = 'l10n_br_fiscal.base.wizard.mixin'

    @api.multi
    def doit(self):
        for wiz in self:
            if wiz.document_id:
                message = _("Cancellation: {}").format(wiz.justification)
                wiz.document_id.with_context(message=message)._document_cancel()
        return {'type': 'ir.actions.act_window_close'}

## Instruction:
Update Fiscal document cancel wizard
## Code After:

from odoo import api, models


class DocumentCancelWizard(models.TransientModel):
    _name = 'l10n_br_fiscal.document.cancel.wizard'
    _description = 'Fiscal Document Cancel Wizard'
    _inherit = 'l10n_br_fiscal.base.wizard.mixin'

    @api.multi
    def doit(self):
        for wizard in self:
            if wizard.document_id:
                wizard.document_id._document_cancel(wizard.justification)
        self._close()
