
import time
from openerp import models, api
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT


class PosPicking(models.Model):
    _inherit = 'pos.order'

    @api.multi
    def create_picking(self):
        try:
            super(PosPicking, self).create_picking()
        except:
            if self.picking_id.state != 'done':
                for move in self.picking_id.move_lines:
                    if move.quant_ids:
                        # We pass this move to done because the quants were already moved
                        move.write({'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
                    else:
                        # If there are no moved quants we pass the move to Waiting Availability
                        move.do_unreserve()
        return True


import time
from openerp import models, api
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT


class PosPicking(models.Model):
    _inherit = 'pos.order'

    @api.multi
    def create_picking(self):
        try:
            super(PosPicking, self).create_picking()
        except:
            pass

        if self.picking_id.state != 'done':
            for move in self.picking_id.move_lines:
                if move.quant_ids:
                    # We pass this move to done because the quants were already moved
                    move.write({'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
                else:
                    # If there are no moved quants we pass the move to Waiting Availability
                    move.do_unreserve()
        return True

Move code outside of exception
[FIX] Move code outside of exception

  
  import time
  from openerp import models, api
  from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
  
  
  class PosPicking(models.Model):
      _inherit = 'pos.order'
  
      @api.multi
      def create_picking(self):
          try:
              super(PosPicking, self).create_picking()
          except:
+             pass
+ 
-             if self.picking_id.state != 'done':
+         if self.picking_id.state != 'done':
-                 for move in self.picking_id.move_lines:
+             for move in self.picking_id.move_lines:
-                     if move.quant_ids:
+                 if move.quant_ids:
-                         # We pass this move to done because the quants were already moved
+                     # We pass this move to done because the quants were already moved
-                         move.write({'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
+                     move.write({'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
-                     else:
+                 else:
-                         # If there are no moved quants we pass the move to Waiting Availability
+                     # If there are no moved quants we pass the move to Waiting Availability
-                         move.do_unreserve()
+                     move.do_unreserve()
          return True
  
Move code outside of exception
## Code Before:

import time
from openerp import models, api
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT


class PosPicking(models.Model):
    _inherit = 'pos.order'

    @api.multi
    def create_picking(self):
        try:
            super(PosPicking, self).create_picking()
        except:
            if self.picking_id.state != 'done':
                for move in self.picking_id.move_lines:
                    if move.quant_ids:
                        # We pass this move to done because the quants were already moved
                        move.write({'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
                    else:
                        # If there are no moved quants we pass the move to Waiting Availability
                        move.do_unreserve()
        return True

## Instruction:
Move code outside of exception
## Code After:

import time
from openerp import models, api
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT


class PosPicking(models.Model):
    _inherit = 'pos.order'

    @api.multi
    def create_picking(self):
        try:
            super(PosPicking, self).create_picking()
        except:
            pass

        if self.picking_id.state != 'done':
            for move in self.picking_id.move_lines:
                if move.quant_ids:
                    # We pass this move to done because the quants were already moved
                    move.write({'state': 'done', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
                else:
                    # If there are no moved quants we pass the move to Waiting Availability
                    move.do_unreserve()
        return True
