'Changes the Product Quantity by making a Physical Inventory.'

@api.multi
def change_product_qty(self):

    Inventory = self.env['stock.inventory']
    for wizard in self:
        product = wizard.product_id.with_context(location=wizard.location_id.id, lot_id=wizard.lot_id.id)
        line_data = wizard._prepare_inventory_line()
        if (wizard.product_id.id and wizard.lot_id.id):
            inventory_filter = 'none'
        elif wizard.product_id.id:
            inventory_filter = 'product'
        else:
            inventory_filter = 'none'
        inventory = Inventory.create({'name': (_('INV:    %s') % tools.ustr(wizard.product_id.name)), 'filter': inventory_filter, 'product_id': wizard.product_id.id, 'location_id': wizard.location_id.id, 'lot_id': wizard.lot_id.id, 'line_ids': [(0, 0, line_data)]})
        inventory.action_done()
    return {'type': 'ir.actions.act_window_close'}
