
from odoo import api, models


class SaleOrderConfirmWizard(models.TransientModel):
    _name = "sale.order.confirm.wizard"
    _description = "Wizard - Sale Order Confirm"

    @api.multi
    def confirm_sale_orders(self):
        self.ensure_one()
        active_ids = self._context.get('active_ids')
        orders = self.env['sale.order'].browse(active_ids)
        orders.action_confirm()


from odoo import models, api


class SaleOrderConfirmWizard(models.TransientModel):
    _name = "sale.order.confirm.wizard"
    _description = "Wizard - Sale Order Confirm"

    @api.multi
    def confirm_sale_orders(self):
        self.ensure_one()
        active_ids = self._context.get('active_ids')
        orders = self.env['sale.order'].browse(active_ids)
        for order in orders:
            if order.state in ['draft', 'sent']:
                order.action_confirm()

Make sure only Sales Order with state in 'draft' or 'sent' is confirmed (state 'canceled' will not be confirmed)
Make sure only Sales Order with state in 'draft' or 'sent' is confirmed (state 'canceled' will not be confirmed)

  
- from odoo import api, models
+ from odoo import models, api
  
  
  class SaleOrderConfirmWizard(models.TransientModel):
      _name = "sale.order.confirm.wizard"
      _description = "Wizard - Sale Order Confirm"
  
      @api.multi
      def confirm_sale_orders(self):
          self.ensure_one()
          active_ids = self._context.get('active_ids')
          orders = self.env['sale.order'].browse(active_ids)
+         for order in orders:
+             if order.state in ['draft', 'sent']:
-         orders.action_confirm()
+                 order.action_confirm()
  
Make sure only Sales Order with state in 'draft' or 'sent' is confirmed (state 'canceled' will not be confirmed)
## Code Before:

from odoo import api, models


class SaleOrderConfirmWizard(models.TransientModel):
    _name = "sale.order.confirm.wizard"
    _description = "Wizard - Sale Order Confirm"

    @api.multi
    def confirm_sale_orders(self):
        self.ensure_one()
        active_ids = self._context.get('active_ids')
        orders = self.env['sale.order'].browse(active_ids)
        orders.action_confirm()

## Instruction:
Make sure only Sales Order with state in 'draft' or 'sent' is confirmed (state 'canceled' will not be confirmed)
## Code After:

from odoo import models, api


class SaleOrderConfirmWizard(models.TransientModel):
    _name = "sale.order.confirm.wizard"
    _description = "Wizard - Sale Order Confirm"

    @api.multi
    def confirm_sale_orders(self):
        self.ensure_one()
        active_ids = self._context.get('active_ids')
        orders = self.env['sale.order'].browse(active_ids)
        for order in orders:
            if order.state in ['draft', 'sent']:
                order.action_confirm()
